CStringA 到 CStringW 的隐式转换使用哪个代码页?

问题描述 投票:0回答:1

我出于好奇才问这个问题。

考虑这个代码片段:

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 遗留软件。

c++ mfc atl
1个回答
0
投票

ATL 是开源的。 ATL

StringT
使用
_AtlGetConversionACP()
:

inline UINT WINAPI _AtlGetConversionACP() throw()
{
#ifdef _CONVERSION_DONT_USE_THREAD_LOCALE
    return CP_ACP;
#else
    return CP_THREAD_ACP;
#endif
}
© www.soinside.com 2019 - 2024. All rights reserved.