SetThreadLocale and UTF8

So I want to use SetThreadLocale to set the codepage of threads to UTF8. So far I have used the second atl string conversion macro parameter, for example, "CT2A (szBUF, CP_UTF8)". But I want to be able to set the code chain once at the beginning with SetThreadLocale () and never again use the second parameter of the conversion macro.

How can I do it? SetThreadLocale will not use a codepage parameter such as CP_UTF8, only LCID. What parameters should I feed SetThreadLocale to achieve this?

Keep in mind that I do not have a specific language. The strings I get can be Japanese, Korean, English, etc. So far, I have no problem with this string join when specifying CP_UTF8 as the second parameter of the conversion macro. You may ask "well then why not just use the second parameter." The answer is "because it can easily be forgotten by team members working on code. It would be nice if it just worked correctly, using the default version of parameter 1 for the conversion macro."

+3
source share
1 answer

SetThreadLocale , UTF-8 - Unicode. - , ANSI 128-255. , . UTF-8, OTOH, Unicode. UTF-8, Unicode. ANSI, , . , "", ANSI UTF-8, MultiByteToWideChar , Unicode UTF-8.

, - . paramepage , , ( CT2A ).

+5

Source: https://habr.com/ru/post/1711504/


All Articles