[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

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?
0
simonsmi
Asked:
simonsmi
  • 7
  • 2
  • 2
1 Solution
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now