UNICODE/Code Pages

I am writing a UNICODE application and need to call WideCharToMultiByte as I need to create a non-UNICODE text file for backwards compatability. Only thing is, i need to pass the code page to the function. How do I know generically whether to pass CP_ACP or CP_OEMCP. i.e. how can I tell whether the installed code page is a standard ANSI one or an OEM-installed one?

I know of the functions GetACP and GetOEMCP but which one should I use?
simonsmiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
You pass whichever one you want.  What format do you want the end result to be in?
0
inprasCommented:
Hi simonsmi
Use the Function GEtCPInfo(); which will tell U through CPINFO structure which further function to use either GetACP() or GetOEMCP() functions
Regards
0
nietodCommented:
>> the Function GEtCPInfo(); which will tell U
How?  You can use either code page--actually any code page.  Its up to you to choose what code page you want to use, based on your needs.  GetCPInfo() can't tell you which one to use, because it doesn't know your needs.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

inprasCommented:
Hi nietod
As the Help in VC says
The GetCPInfo function retrieves information about any valid installed or available code page.

BOOL GetCPInfo( UINT CodePage,
 // code page identifier
 
LPCPINFO lpCPInfo
 // address of structure for information
);

and CPINFO structure will return U the type of code page

Thanks
 
0
nietodCommented:
But what good is that?  He needs to choose which code page to use.  How does this help you to choose?  It doesn't
0
simonsmiAuthor Commented:
I want to use the code page for whatever language is being used in NT4. e.g. if Arabic is being used then I want to use the code page relevant to this. The question is how to I determine the current language being used?

If I mis-understand how this works, then can yoyu provide a full explanation of how code pages work.
 
0
nietodCommented:
You can use GetThreadLocale() to get the locale ID.  Then use GetLocalInfo() with LOCALE_IDEFAULTCODEPAGE to get the code page associated with the locale.
0
nietodCommented:
You could also use GetSystemDefaultLCID() or GetuserDefaultLCID() to get the local ID.
0
simonsmiAuthor Commented:
nietod is right in what he says. GetCPInfo does not tell me which code page I need to use. I need to give the points to nietod as he has provided the answer I needed in his last two comments.
0
nietodCommented:
Thanks.  

there is also now a feature to accept a comment as an answer.  When there is no pending answer, the comment boxes should have a link for this.  (Not now because I've answered.)  You could have used this feature.
0
nietodCommented:
opps, that was supposed to be an answer.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.