{"id":3343,"date":"2005-03-06T01:23:00","date_gmt":"2005-03-06T01:23:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2005\/03\/06\/new-locale-dependent-c-runtime-functions\/"},"modified":"2005-03-06T01:23:00","modified_gmt":"2005-03-06T01:23:00","slug":"new-locale-dependent-c-runtime-functions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/new-locale-dependent-c-runtime-functions\/","title":{"rendered":"New Locale-dependent C Runtime Functions"},"content":{"rendered":"<p>In <a href=\"http:\/\/blogs.msdn.com\/michkap\/archive\/2005\/03\/05\/386021.aspx\">&#8220;POSIX&#8221; style locale support on Windows?<\/a>, Michael Kaplan, the Technical Lead for Windows Globalization, describes the existing <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/vclib\/html\/_crt_locale.asp\">locale-dependent functions<\/a> in the&nbsp;C Runtime (CRT)&nbsp;as &#8220;unwieldy&#8221;. To compare strings, for example, using&nbsp;a different locale than is currently set for the process or thread you must call <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/vccore98\/html\/_crt_setlocale.2c_._wsetlocale.asp\"><font face=\"Courier New\">setlocale()<\/font><\/a> to set the desired locale and to get the old locale, call the function or functions, then call <font face=\"Courier New\">setlocale()<\/font> again using the old locale. Someone Michael mentions in his blog suggests that locale-dependent functions should accept a locale instead, like the managed <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/cpref\/html\/frlrfsystemstringclasscomparetopic.asp\"><font face=\"Courier New\">String.Compare()<\/font><\/a> method.<\/p>\n<p>The <a href=\"http:\/\/msdn2.microsoft.com\/library\/59ey50w6.aspx\">CRT<\/a> shipping with Whidbey adds that capability using the new <a href=\"http:\/\/msdn2.microsoft.com\/library\/wyzd2bce.aspx\">locale-dependent functions<\/a> that are similar to the old functions, but end in <font face=\"Courier New\">_l<\/font> and accept a parameter of type <font face=\"Courier New\">_locale_t<\/font>, like <a href=\"http:\/\/msdn2.microsoft.com\/library\/k59z8dwe.aspx\"><font face=\"Courier New\">_stricmp_l()<\/font><\/a>. As an alternative to setting and resetting the process or thread locale, you can create and store a <font face=\"Courier New\">_locale_t<\/font> variable returned from <a href=\"http:\/\/msdn2.microsoft.com\/library\/4zx9aht2.aspx\"><font face=\"Courier New\">_create_locale()<\/font><\/a> that accepts the same parameters as <font face=\"Courier New\">setlocale()<\/font>. When appropriate, the Secure CRT functions &#8211; similar in nature to the functionality that <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/winui\/windowsuserinterface\/resources\/strings\/usingstrsafefunctions.asp\">strsafe.h<\/a> provides &#8211; are defined to accept a locale, like <a href=\"http:\/\/msdn2.microsoft.com\/library\/5dae5d43.aspx\">strncpy_s_l()<\/a>.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In &#8220;POSIX&#8221; style locale support on Windows?, Michael Kaplan, the Technical Lead for Windows Globalization, describes the existing locale-dependent functions in the&nbsp;C Runtime (CRT)&nbsp;as &#8220;unwieldy&#8221;. To compare strings, for example, using&nbsp;a different locale than is currently set for the process or thread you must call setlocale() to set the desired locale and to get the [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[14,22],"class_list":["post-3343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-development","tag-localization"],"acf":[],"blog_post_summary":"<p>In &#8220;POSIX&#8221; style locale support on Windows?, Michael Kaplan, the Technical Lead for Windows Globalization, describes the existing locale-dependent functions in the&nbsp;C Runtime (CRT)&nbsp;as &#8220;unwieldy&#8221;. To compare strings, for example, using&nbsp;a different locale than is currently set for the process or thread you must call setlocale() to set the desired locale and to get the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/3343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=3343"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/3343\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=3343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=3343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=3343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}