named locales using VS2002 
Author Message
 named locales using VS2002

This may not be the proper newgroup for this question but I couldn't
find one that I thought was more relevant, so forgive me if I am
off-topic,
using the library that comes with VS2002, where can I find out what
are the named locales that you can use to create a locale and not
throw a runtime error. For e.g.,
                locale Loc("French_switzerland");
                locale Loc("Spanish_spain");
both work, but any of the following throw:
                locale Loc("Korean_Korea");
                locale Loc("Korean_southkorea");
                locale Loc("En_US");
                locale Loc("Fr_CH");

If I am off, can you please refer me to the right place. I can't seem
to find any specifics in the help file(s) that come with
Microsoft Visual C++ .NET   55538-700-0716185-18246.

Thanks in advance



Sun, 28 Aug 2005 08:47:34 GMT  
 named locales using VS2002
It uses EnumSystemLocales to enumerate all locales. For each locale, it
uses GetLocaleInfo with the following flags: LOCALE_SENGCOUNTRY or
LOCALE_SABBREVCTRYNAME for country, LOCALE_SENGLANGUAGE or
LOCALE_SABBREVLANGNAME for language. It then matches the values Windows
returns with what you pass in. There are also two hardcoded fix-up
tables at the top of getqloc.c (in CRT sources) - those are applied
first, then EnumSystemLocales pass is made. You can use any combination
of short and long names for country and language.

English (US) will be recognized as "ENU_US" or "ENU_USA" or simply
"ENU". French (Switzerland) is FRS or FRS_CHE or "french-swiss" (with
dash, not underscore). I don't have korean locale installed so can't
check that.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Quote:
> This may not be the proper newgroup for this question but I couldn't
> find one that I thought was more relevant, so forgive me if I am
> off-topic,
> using the library that comes with VS2002, where can I find out what
> are the named locales that you can use to create a locale and not
> throw a runtime error. For e.g.,
> locale Loc("French_switzerland");
> locale Loc("Spanish_spain");
> both work, but any of the following throw:
> locale Loc("Korean_Korea");
> locale Loc("Korean_southkorea");
> locale Loc("En_US");
> locale Loc("Fr_CH");

> If I am off, can you please refer me to the right place. I can't seem
> to find any specifics in the help file(s) that come with
> Microsoft Visual C++ .NET   55538-700-0716185-18246.

> Thanks in advance



Mon, 29 Aug 2005 02:08:26 GMT  
 named locales using VS2002
Thanks so much . Yes inside C:\Program Files\Microsoft Visual Studio
.NET\Vc7\crt\src\getgloc.c are a bunch of hardcoded strings. It seems
that I can use any of them in the locale constructor: For e.g.

        locale L("english-trinidad y tobago");

seems to work as do the others . Thanks very much.

cbb

On Wed, 12 Mar 2003 13:08:26 -0500, "Igor Tandetnik"

Quote:

>It uses EnumSystemLocales to enumerate all locales. For each locale, it
>uses GetLocaleInfo with the following flags: LOCALE_SENGCOUNTRY or
>LOCALE_SABBREVCTRYNAME for country, LOCALE_SENGLANGUAGE or
>LOCALE_SABBREVLANGNAME for language. It then matches the values Windows
>returns with what you pass in. There are also two hardcoded fix-up
>tables at the top of getqloc.c (in CRT sources) - those are applied
>first, then EnumSystemLocales pass is made. You can use any combination
>of short and long names for country and language.

>English (US) will be recognized as "ENU_US" or "ENU_USA" or simply
>"ENU". French (Switzerland) is FRS or FRS_CHE or "french-swiss" (with
>dash, not underscore). I don't have korean locale installed so can't
>check that.



Tue, 30 Aug 2005 02:31:29 GMT  
 named locales using VS2002
Those form just a small portion of what you can use. The rest comes
directly from the OS. Use the program below to get the list of all
supported identifiers for your machine:

#include <windows.h>
#include <stdio.h>

BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
{
 LCID lcid;
 sscanf(lpLocaleString, "%x", &lcid);

 char country[128];
 char abbrevCountry[128];
 char lang[128];
 char abbrevLang[128];
 GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, country, 128);
 GetLocaleInfo(lcid, LOCALE_SABBREVCTRYNAME, abbrevCountry, 128);
 GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang, 128);
 GetLocaleInfo(lcid, LOCALE_SABBREVLANGNAME, abbrevLang, 128);
 printf("%s(%s)_%s(%s)\n", lang, abbrevLang, country, abbrevCountry);
 return TRUE;

Quote:
}

int main ()
{
 EnumSystemLocales(EnumLocalesProc, LCID_INSTALLED);
 return 0;

Quote:
}

To select a locale that this program lists as, say

French(FRS)_Switzerland(CHE)

you can specify any of the following in std::locale constructor:

French_Switzerland
French_CHE
FRS
FRS_Switzerland
FRS_CHE

--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Quote:
> Thanks so much . Yes inside C:\Program Files\Microsoft Visual Studio
> .NET\Vc7\crt\src\getgloc.c are a bunch of hardcoded strings. It seems
> that I can use any of them in the locale constructor: For e.g.

> locale L("english-trinidad y tobago");

> seems to work as do the others . Thanks very much.

> cbb

> On Wed, 12 Mar 2003 13:08:26 -0500, "Igor Tandetnik"

> >It uses EnumSystemLocales to enumerate all locales. For each locale,
it
> >uses GetLocaleInfo with the following flags: LOCALE_SENGCOUNTRY or
> >LOCALE_SABBREVCTRYNAME for country, LOCALE_SENGLANGUAGE or
> >LOCALE_SABBREVLANGNAME for language. It then matches the values
Windows
> >returns with what you pass in. There are also two hardcoded fix-up
> >tables at the top of getqloc.c (in CRT sources) - those are applied
> >first, then EnumSystemLocales pass is made. You can use any
combination
> >of short and long names for country and language.

> >English (US) will be recognized as "ENU_US" or "ENU_USA" or simply
> >"ENU". French (Switzerland) is FRS or FRS_CHE or "french-swiss" (with
> >dash, not underscore). I don't have korean locale installed so can't
> >check that.



Tue, 30 Aug 2005 02:57:45 GMT  
 named locales using VS2002
Hey thanks again. I ran your program on my system and here is what it
returned; you weren't kidding when you said the header file getgloc.c
only showed a "small portion"!!!!!!

Catalan(CAT)_Spain(ESP)
Chinese(CHT)_Taiwan(TWN)
Danish(DAN)_Denmark(DNK)
German(DEU)_Germany(DEU)
English(ENU)_United States(USA)
Spanish(ESP)_Spain(ESP)
Finnish(FIN)_Finland(FIN)
French(FRA)_France(FRA)
Hebrew(HEB)_Israel(ISR)
Icelandic(ISL)_Iceland(ISL)
Italian(ITA)_Italy(ITA)
Japanese(JPN)_Japan(JPN)
Dutch(NLD)_Netherlands(NLD)
Norwegian(NOR)_Norway(NOR)
Portuguese(PTB)_Brazil(BRA)
Swedish(SVE)_Sweden(SWE)
Indonesian(IND)_Indonesia(IDN)
Basque(EUQ)_Spain(ESP)
Afrikaans(AFK)_South Africa(ZAF)
Faeroese(FOS)_Faeroe Islands(FRO)
Malay(MSL)_Malaysia(MYS)
Swahili(SWK)_Kenya(KEN)
Chinese(CHS)_People's Republic of Chin
German(DES)_Switzerland(CHE)
English(ENG)_United Kingdom(GBR)
Spanish(ESM)_Mexico(MEX)
French(FRB)_Belgium(BEL)
Italian(ITS)_Switzerland(CHE)
Dutch(NLB)_Belgium(BEL)
Norwegian(NON)_Norway(NOR)
Portuguese(PTG)_Portugal(PRT)
Swedish(SVF)_Finland(FIN)
Malay(MSB)_Brunei Darussalam(BRN)
Chinese(ZHH)_Hong Kong(HKG)
German(DEA)_Austria(AUT)
English(ENA)_Australia(AUS)
Spanish(ESN)_Spain(ESP)
French(FRC)_Canada(CAN)
Chinese(ZHI)_Singapore(SGP)
German(DEL)_Luxembourg(LUX)
English(ENC)_Canada(CAN)
Spanish(ESG)_Guatemala(GTM)
French(FRS)_Switzerland(CHE)
Chinese(ZHM)_Macau(MCO)
German(DEC)_Liechtenstein(LIE)
English(ENZ)_New Zealand(NZL)
Spanish(ESC)_Costa Rica(CRI)
French(FRL)_Luxembourg(LUX)
English(ENI)_Ireland(IRL)
Spanish(ESA)_Panama(PAN)
French(FRM)_Principality of Monaco(MCO
English(ENS)_South Africa(ZAF)
Spanish(ESD)_Dominican Republic(DOM)
English(ENJ)_Jamaica(JAM)
Spanish(ESV)_Venezuela(VEN)
English(ENB)_Caribbean(CAR)
Spanish(ESO)_Colombia(COL)
English(ENL)_Belize(BLZ)
Spanish(ESR)_Peru(PER)
English(ENT)_Trinidad y Tobago(TTO)
Spanish(ESS)_Argentina(ARG)
English(ENW)_Zimbabwe(ZWE)
Spanish(ESF)_Ecuador(ECU)
English(ENP)_Republic of the Philippin
Spanish(ESL)_Chile(CHL)
Spanish(ESY)_Uruguay(URY)
Spanish(ESZ)_Paraguay(PRY)
Spanish(ESB)_Bolivia(BOL)
Spanish(ESE)_El Salvador(SLV)
Spanish(ESH)_Honduras(HND)
Spanish(ESI)_Nicaragua(NIC)
Spanish(ESU)_Puerto Rico(PRI)

On Thu, 13 Mar 2003 13:57:45 -0500, "Igor Tandetnik"

Quote:

>Those form just a small portion of what you can use. The rest comes
>directly from the OS. Use the program below to get the list of all
>supported identifiers for your machine:

>#include <windows.h>
>#include <stdio.h>

>BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
>{
> LCID lcid;
> sscanf(lpLocaleString, "%x", &lcid);

> char country[128];
> char abbrevCountry[128];
> char lang[128];
> char abbrevLang[128];
> GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, country, 128);
> GetLocaleInfo(lcid, LOCALE_SABBREVCTRYNAME, abbrevCountry, 128);
> GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang, 128);
> GetLocaleInfo(lcid, LOCALE_SABBREVLANGNAME, abbrevLang, 128);
> printf("%s(%s)_%s(%s)\n", lang, abbrevLang, country, abbrevCountry);
> return TRUE;
>}

>int main ()
>{
> EnumSystemLocales(EnumLocalesProc, LCID_INSTALLED);
> return 0;
>}

>To select a locale that this program lists as, say

>French(FRS)_Switzerland(CHE)

>you can specify any of the following in std::locale constructor:

>French_Switzerland
>French_CHE
>FRS
>FRS_Switzerland
>FRS_CHE



Tue, 30 Aug 2005 03:07:17 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Names of locales on Win

2. Windows locale LCID and std::locale

3. simple example of using locale info

4. Object required error message in VS2002

5. HOWTO: format a number using locale ?

6. using different locales with time_put::put

7. Anyone using locale &/or facets with Windows

8. How retrive TrueType Font file name using only face name

9. interesting statement: name = (name)?name:"";

10. call winform by using its name

11. When I rename objects in the code the old name is still used

12. Getting the executable's name without using argv[0]

 

 
Powered by phpBB® Forum Software