How to get a right character when we use cmd command

This is my runtime environment

$Version$CharacterEncoding


"11.1.1 for Microsoft Windows (64-bit) (May 16, 2017)"

"CP936"

When I run

SetDirectory["C:/Windows/AppPatch"];
RunProcess["cmd", "StandardOutput", "dir\n"]


I get a such output

I know the wrong character is Chinese character. How to show it correctlly?

run[cmdLine_] := Module[{out},
RunProcess[{$SystemShell, "/c", cmdLine <> ">test.txt"}]["StandardOutput"]; out = Import["test.txt", CharacterEncoding -> "CP936"]; DeleteFile["test.txt"]; out] run["echo 你好"]  "你好" run["dir"]  Second method: Import["!echo hello 你好", "Text", CharacterEncoding -> "CP936"]  "hello 你好" Import["!dir\n", "Text", CharacterEncoding -> "CP936"] (*also works*)  More cleaner. Just make a note here. ImportString[ RunProcess[$SystemShell, "StandardOutput", "dir\n"], "Text",

• It isn't clear for what purpose you use FromCharacterCode here: ImportString already returns a grid of strings. It would be more correct to specify "Text" as second argument to ImportString. – Alexey Popkov Oct 30 '17 at 8:23
• @AlexeyPopkov Another thing about it, Since ImportString // Options don't include option CharacterEncoding, but we can use it. It is a bug of ImportString? – yode Oct 30 '17 at 8:30
• The CharacterEncoding option is listed on the Docs page for the "Text" import format, there is no bug of course. – Alexey Popkov Oct 30 '17 at 8:38