Locale

Locale

Post by Tuukka Leh » Mon, 29 Aug 2005 03:05:25


I try to detect and set user locale information for C library.
I got idea to use GetLocaleInfo and setlocale. But there is
couple of opening questions.

How long buffer must have ?
- What is longest language name for right buffer size.
If user Windows version isn't are English does this succeed ?
- Does GetLocaleInfo return always English names.

GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, buf, MAX_PATH);
setlocale( LC_ALL, buf);
 
 
 

Locale

Post by Andreas Ma » Tue, 30 Aug 2005 03:15:15

Hi Tuukka,

"Tuukka Lehtinen" < XXXX@XXXXX.COM > schrieb im Newsbeitrag


int GetLocaleInfo(
LCID Locale, // locale identifier
LCTYPE LCType, // information type
LPTSTR lpLCData, // information buffer
int cchData // size of buffer
);

You can call the function with cchData set to zero. Then GetLocaleInfo
returns the requested buffer size in TCHARS.


This is not documented...


Why not use GetSystemDefaultLCID? You then get a LCID and no independent
language string...

Regards,
A.Martin

 
 
 

Locale

Post by Tuukka Leh » Wed, 31 Aug 2005 06:47:23


I want put C library in right locale, whit out changing the code page.
This will effect printf() number format.
 
 
 

Locale

Post by Antoine Le » Wed, 31 Aug 2005 23:48:10


Strange idea. Just call

setlocale(LC_ALL, "")

and you are done.



Antoine