c++ 哪个代码页用于CStringA到CStringW的隐式转换?

v440hwme  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(74)

我问这个更多是出于好奇。
考虑以下代码片段:

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 = CA2W(narrow, CP_ACP);而不是wide = narrow;,这样我就可以显式地指定所需的代码页。
免责声明:我知道宽字符串应该在所有地方使用,但这是用于MBCS遗留软件。

yacmzcpb

yacmzcpb1#

ATL是开源的。ATL StringT使用_AtlGetConversionACP()

inline UINT WINAPI _AtlGetConversionACP() throw()
{
#ifdef _CONVERSION_DONT_USE_THREAD_LOCALE
    return CP_ACP;
#else
    return CP_THREAD_ACP;
#endif
}

字符串

相关问题