serg111
asked on
How to get current codepage?
How can I findout what codepage is currntly used by user?
ASKER
The GetThreadLocale() function returns the calling thread's current locale.
In my case it always return 1033 - is it language ID?
If I change Input language of edit control - this function still return 1033
I'd like to findout codepage number that are listed under
HKEY_CLASSES_ROOT\MIME\Dat abase\Code page\
In my case it always return 1033 - is it language ID?
If I change Input language of edit control - this function still return 1033
I'd like to findout codepage number that are listed under
HKEY_CLASSES_ROOT\MIME\Dat
Locale IDs (LCIDs) are not the same as codepages. 1033 is the decimal locale id for U.S. English.
Try _getmbcp() -- it returns an int which is the current multibyte codepage.
Try _getmbcp() -- it returns an int which is the current multibyte codepage.
ASKER
In which DLL is this function? I cant find it on my computer with WinXP :-(
It's in the C runtime libraries. You might need to include the header file mbctype.h.
ASKER
I am using borland C and it doesn't have this function in mbctype.h
Do you know what library does contain this function?
Do you know what library does contain this function?
Borland C -- which version exactly?
ASKER
This is Version 5.02
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've got 2 errors with this code :-(
undefined symbol: langLCID
undefined symbol: LOCALE_RETURN_NUMBER
undefined symbol: langLCID
undefined symbol: LOCALE_RETURN_NUMBER
The langLCID is the value get from e.g. GetUserDefaultLCID() or some other functions. The other
is define, defined somewhere is win32-includes (in my MS Visual.NET it's winnls.h, but only Win98
and later). See documentation for GetLocaleInfo().
is define, defined somewhere is win32-includes (in my MS Visual.NET it's winnls.h, but only Win98
and later). See documentation for GetLocaleInfo().
ASKER
OK, it works without LOCALE_RETURN_NUMBER too
but it always return langCP=1252 - English/US
even when I switch to different input language and type in characters in different languages
I think it should return different codepage number for different languages?
but it always return langCP=1252 - English/US
even when I switch to different input language and type in characters in different languages
I think it should return different codepage number for different languages?
The LOCALE_RETURN_NUMBER flag only force the GetLocaleInfo-function to return CP in numeric (integer) form, instead of string form (which is default behavior), Without this flag you must change typ of 'langCP' from UINT to char[].
For thread_LCID=1033 is CP=1252, so it's o.k.
For just active input language try this:
HKL input_locale_identifier = GetKeyboardLayout(0);
LANGID language_identifier = LOWORD(input_locale_identi fier);
LCID locale_identifier = MAKELCID(language_identifi er, SORT_DEFAULT);
GetLocaleInfo(locale_ident ifier,...) ;
And for handling of dynamically changed keyboard layout you should process the WM_INPUTLANGCHANGE message.
For thread_LCID=1033 is CP=1252, so it's o.k.
For just active input language try this:
HKL input_locale_identifier = GetKeyboardLayout(0);
LANGID language_identifier = LOWORD(input_locale_identi
LCID locale_identifier = MAKELCID(language_identifi
GetLocaleInfo(locale_ident
And for handling of dynamically changed keyboard layout you should process the WM_INPUTLANGCHANGE message.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_08tg.asp
Also you can use WinAPI's GetThreadLocale() function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_9ko5.asp