{"id":218,"date":"2007-03-29T11:29:46","date_gmt":"2007-03-29T09:29:46","guid":{"rendered":"https:\/\/alax.info\/blog\/218"},"modified":"2008-04-03T21:07:01","modified_gmt":"2008-04-03T19:07:01","slug":"string-resource-problembug-setthreadlocale-_conversion_dont_use_thread_locale","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/218","title":{"rendered":"STRING resource problem\/bug (SetThreadLocale, _CONVERSION_DONT_USE_THREAD_LOCALE)"},"content":{"rendered":"<p>There has been an unexpected problem localizing application resources when <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa381050.aspx\">STRING<\/a> resources failed to load while there were no problems with other resource types. The source of the problem appears to be within ATL core. As long as <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms776420.aspx\">CP_THREAD_ACP<\/a> is involved in ATL&#8217;s conversion the loaded string is screwed.<br \/>\nThe problem is illustrated by the sample. The same string resource is loaded with <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms647486.aspx\">LoadString<\/a> API and <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/a44fb3wy(VS.80).aspx\">CString::LoadString<\/a> ATL function. The difference is emphasized with bold below. As soon as Russian string is loaded from a thread with non-Russian thread locale, the string is screwed but only when loaded through ATL class (<em>warning: Russian characters seems to be forged by WordPress in quoted text below<\/em>):<\/p>\n<blockquote><p><em>C:\\&gt;ThreadLocaleSample01.exe<\/em><br \/>\nDefault Thread Locale: 1033 (0x409), Primary Language 9 (0x9), SubLanguage 1 (0x1), Sort 0 (0x0)<br \/>\nString 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nString 102: ????????????????????????????????<br \/>\nATL String 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nATL String 102: ????????????????????????????????<br \/>\nRussian Locale: 1049 (0x419), Primary Language 25 (0x19), SubLanguage 1 (0x1), Sort 0 (0x0)<br \/>\nString 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nString 102: ????????????????????????????????<br \/>\nATL String 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nATL String 102: ????????????????????????????????<br \/>\nEnglish Locale: 1033 (0x409), Primary Language 9 (0x9), SubLanguage 1 (0x1), Sort 0 (0x0)<br \/>\nString 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nString 102: ????????????????????????????????<br \/>\nATL String 101: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br \/>\nATL String 102: ????????????????????????????????<\/p><\/blockquote>\n<p><!--more--><\/p>\n<p>The workaround for the problem is one of the following:<\/p>\n<ul>\n<li>define _CONVERSION_DONT_USE_THREAD_LOCALE before including ATL headers<\/li>\n<li>compile in Unicode character set<\/li>\n<\/ul>\n<p>See also:<\/p>\n<ul>\n<li><a href=\"http:\/\/connect.microsoft.com\/VisualStudio\/feedback\/ViewFeedback.aspx?FeedbackID=100887\">_CONVERSION_DONT_USE_THREAD_LOCALE does not work: Won&#8217;t Fix<\/a> on <em>connect.microsoft.com<\/em><\/li>\n<li><a href=\"http:\/\/blogs.msdn.com\/michkap\/archive\/2007\/05\/28\/2960411.aspx\">Nothing stinks worse than the thread locale, other than the thread code page<\/a> on <em>blogs.microsoft.com<\/em><\/li>\n<\/ul>\n<p>Visual C++.NET 2005 source code can be downloaded <a id=\"p113\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2007\/03\/threadlocalesample01.zip\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There has been an unexpected problem localizing application resources when STRING resources failed to load while there were no problems with other resource types. The source of the problem appears to be within ATL core. As long as CP_THREAD_ACP is involved in ATL&#8217;s conversion the loaded string is screwed. The problem is illustrated by the&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/218\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[487,38,56,57,58],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-atl","tag-atl","tag-c","tag-locale","tag-unicode","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}