我出于好奇才问这个问题。
考虑这个代码片段:
CStringA narrow;
CStringW wide;
...
wide = narrow; // which code page is used for the conversion
// of the narrow string to wide string?
哪个代码页用于将
CStringA
字符串转换为 CStringW
?它似乎使用了 CP_ACP
代码页,但这能保证吗?
我实际上使用的是
wide = narrow;
,而不是 wide = CA2W(narrow, CP_ACP);
,因此我可以明确指定所需的代码页。
免责声明:我知道应该在所有地方使用宽字符串,但这是用于 MBCS 遗留软件。
ATL 是开源的。 ATL
StringT
使用 _AtlGetConversionACP()
:
inline UINT WINAPI _AtlGetConversionACP() throw()
{
#ifdef _CONVERSION_DONT_USE_THREAD_LOCALE
return CP_ACP;
#else
return CP_THREAD_ACP;
#endif
}