Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what encoding can the Windows terminal accept Chinese and Russian characters from a program written in C++?

Does anyone know what encoding can be used to send commands to the terminal via a pipe created by the CreatePipe method? Commands with Cyrillic, Russian or Chinese characters must be sent to the terminal. The terminal is created by the CreateProcessW method. Characters are sent to the pipe in UTF-8 encoding. I can't understand why when using UTF-8 encoding the commands in the terminal are displayed correctly, but when executing the command the characters are displayed incorrectly.

PS C:\Users\Forty\AppData\Roaming\TerminalsThisWay> chcp 65001
Active code page: 65001
PS C:\Users\Forty\AppData\Roaming\TerminalsThisWay> cd "D:\Кухонный дед"
cd : Cannot find path 'D:\╨Ъ╤Г╤Е╨╛╨╜╨╜╤Л╨╣ ╨┤╨╡╨┤' because it does not exist.
At line:1 char:1
+ cd "D:\╨Ъ╤Г╤Е╨╛╨╜╨╜╤Л╨╣ ╨┤╨╡╨┤"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\╨Ъ╤Г╤Е╨╛╨╜╨╜╤Л╨╣ ╨┤╨╡╨┤:String) [Set-Location], ItemNotFoundExceptio
   n
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS C:\Users\Forty\AppData\Roaming\TerminalsThisWay> cd "D:\错误写入通道"
cd : Cannot find path 'D:\щФЩшппхЖЩхЕещАЪщБУ' because it does not exist.
At line:1 char:1
+ cd "D:\щФЩшппхЖЩхЕещАЪщБУ"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\щФЩшппхЖЩхЕещАЪщБУ:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
like image 316
dima Avatar asked Jan 26 '26 21:01

dima


1 Answers

When you're using PowerShell to enter the command, it's in utf-16 cause that's what PowerShell uses by default, cmd uses utf-8, so either run cmd or run a few commands to make PowerShell use utf-8.

like image 54
Médi Olivier Avatar answered Jan 28 '26 13:01

Médi Olivier