当我有这样的 C++ 代码时:
std::string narrow( "This is a narrow source string" );
std::string n2( "Win-1252 (that's the encoding we use for source files): ä,ö,ü,ß,€, ..." );
// What encoding should I pass to Win32's `MultiByteToWideChar` function
// to convert these string to a propoer wchar_t (= UTF-16 on Windows)?
如果那是我们的 cpp 文件的(隐式)编码,我可以总是假设 Win-1252 吗?Visual-C++ 编译器如何决定源文件的字符编码?
例如,如果开发人员使用一台机器,其中“普通”文本文件默认为另一种单/多字节编码,会发生什么?
我假设编码只是用于编译代码的机器上的一个问题?也就是说,一旦构建了可执行文件,将静态字符串从固定的窄编码转换为 Windows 的 UTF-16 wchar_t 将始终产生相同的结果,而不管用户 PC 上的语言/区域设置如何?