New Locale-dependent C Runtime Functions

use _create_locale()  and _vcprintf_l() instead setLocale()

 

In "POSIX" style locale support on Windows?, Michael Kaplan, the Technical Lead for Windows Globalization, describes the existing locale-dependent functions in the C Runtime (CRT) as "unwieldy". To compare strings, for example, using 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 old locale, call the function or functions, then call setlocale() again using the old locale. Someone Michael mentions in his blog suggests that locale-dependent functions should accept a locale instead, like the managed String.Compare() method. The CRT shipping with Whidbey adds that capability using the new locale-dependent functions that are similar to the old functions, but end in _l and accept a parameter of type _locale_t, like _stricmp_l(). As an alternative to setting and resetting the process or thread locale, you can create and store a _locale_t variable returned from _create_locale() that accepts the same parameters as setlocale(). When appropriate, the Secure CRT functions - similar in nature to the functionality that strsafe.h provides - are defined to accept a locale, like strncpy_s_l().

 

http://blogs.msdn.com/b/heaths/archive/2005/03/06/386080.aspx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章