2024年4月26日发(作者:)
字符集转换(Character set conversion)
Unicode and character set functions
Recently my Unicode has been engaged in a while ago and wanted
to see MSDN it scorched by the flames! English looks really hard,
in order to save time, translation summary, for future
reference. English level is limited. If there is any
discrepancy, please refer to MSDN.
The first is the wide character to multi byte character
conversion function, and the function prototype is as follows:
Int WideCharToMultiByte (...
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
Int cchWideChar,
LPSTR lpMultiByteStr,
Int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
);
This function converts a wide string to a specified new string,
such as ANSI, UTF8, etc., and the new string does not have to
be a multi byte character set. Parameter:
CodePage: Specifies the character set code page to be converted
to. It can be any set of characters already installed or brought
with the system. You can also use one of the code pages as shown
below.
CP_ACP current system ANSI code page
CP_MACCP current system Macintosh code page
CP_OEMCP the current system OEM code page, a hardware scan code
for the original device manufacturer
CP_SYMBOL Symbol code page for Windows 2000 and later, I don't
understand what it is
CP_THREAD_ACP the current thread ANSI code page for Windows
2000 and later. I don't understand what it is
CP_UTF7 UTF-7, when setting this value, both lpDefaultChar and
lpUsedDefaultChar must be NULL
CP_UTF8 UTF-8, when setting this value, both lpDefaultChar and
lpUsedDefaultChar must be NULL
I think the most common should be CP_ACP and CP_UTF8. The former
converts wide characters to ANSI, and the latter to UTF8.


发布评论