原因是vc的crt最终调用WriteFile写输入输出流,WriteFile对于控制台句柄是调用WriteConsoleA
WriteConsoleA使用当前控制台环境的代码页
因此printf和wprintf最终都得用ANSI编码调用系统服务
由于printf本身就是ansi,所以可以直接把字符串传给WriteFile
wprintf则要把unicode字符串转成ansi,此时用的locale是crt的,crt缺省的是POSIX locale,这个只有很少的功能,不能处理汉字,所以你需要调用setlocale