有谁知道可以使用什么编码通过 CreatePipe 方法创建的管道将命令发送到终端?带有西里尔字母、俄语或中文字符的命令必须发送到终端。终端由 CreateProcessW 方法创建。字符以 UTF-8 编码发送到管道。我不明白为什么当使用UTF-8编码时,终端中的命令显示正确,但执行命令时字符显示不正确。
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
文件系统的文件名是 UTF-16/Unicode/UCS-2,因此您需要使用它而不是 UTF-8。