On windows how can we determine the charset used by the application? On Unix we can use nl_langinfo(CODESET). Is there any similar mechanism on windows?
TIA,
Vivek.
On windows how can we determine the charset used by the application? On Unix we can use nl_langinfo(CODESET). Is there any similar mechanism on windows?
TIA,
Vivek.
I didnt get any function/mechanism for determining the codepage of application's locale. Most of the function descriptions talk about system default locale. My need is to get the code page of the locale used by the application. A more detailed help would be of great help.
TIA,
Vivek
Your application uses the "C" locale by default ( 7 Bit ASCII ).
You can query your codepage by using the returnvalue of the setlocale function;
or MS Unicode specific macros:Code:char* loc = setlocale( LC_ALL, NULL );
You can set the applications codepage to the current windows codepage by passing an empty string:Code:LPTSTR lpszCodePage = _tsetlocale( LC_ALL, NULL );
MS Unicode Macros:Code:char* loc = setlocale( LC_ALL, "" );
You can also pass any codepage name to select that codepage for your application.Code:LPTSTR lpszCodePage = _tsetlocale( LC_ALL, _T("") );
More info here
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Well, GetCPInfo() is in that section of MSDN but they talk about it any.
Use the "See Also" links, TOC pane on the left, and the search feature on MSDN to dig in further.
Using standard C functions is an option as well - as nvoigt has shown.
gg
It depends on what exactly you are trying to do. It sounds like you are looking for the thread code page. This can be determined by calling GetThreadLocale followed by GetLocaleInfo with LOCALE_IDEFAULTANSICODEPAGE.Originally Posted by techi_talk
However, this is not the end of the matter. The C runtime library may use another code page. This can be determined with setlocale and _getmbcp.
The system code page may differ from the current thread code page. Some functions use the system code page rather than the thread code page as the concept of thread specific code pages was only introduced in 2000/XP. The system code page can be obtained with GetACP.
If the file system uses FAT rather than NTFS (which uses unicode), then it too may use a different code page. This can be obtained with GetOEMCP.
The console may use different code pages. These can be obtained with GetConsoleCP and GetConsoleOutputCP.
All of this should not be confused with the preferred user interface language which can be obtained with GetUserDefaultUILanguage.
It is strongly recommended that you avoid this mess and make use of unicode. Unicode is supported natively on NT/2000/XP and with the help of the Microsoft Layer for Unicode on 9x.