Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 10th, 2006, 04:55 PM
recover
Guest
 
Posts: n/a
Default How can I convert UNICODEwchar to ANSIC_char using STL.

#include <xxx>
int main()
{
const wchar* pwcHello=L"hello";
char* pcHello;
xxxxxx //do something using stl
cout<<pcHello<<endl;
}

=============out===========
hello
====end out========

I know in Windows,I can use WideCharToMultiByte to convert wchar_t Encoding
in Unicode to char Encoding in ANSI .

How can I do this using STL?



--
= = = = = = = = = = = = = = = = = = = = = =

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡

ÕÅÖ¾¸Õ
----------------------------
Co.: ±±¾©ÁéͼÐÇѶ¿Æ¼¼ÓÐÏÞ¹«Ë¾ Ñз¢²¿
Ad.: ±±¾©Êк£µíÇøÖйشåÈí¼þÔ°ººÍõ´óÏöþ²ãDÇø
ZIP£º 100094
Tel.: 010-82825800£*8006
Mobile:
Mail£ºzhangzhigang@lingtu.com
MSN: recover_su@hotmail.com
¹«Ë¾£º http://www.lingtu.com/
ÁéͼÔÚÏß:http://www.51ditu.com/
--------------------------


  #2  
Old August 10th, 2006, 05:25 PM
Kirit Sælensminde
Guest
 
Posts: n/a
Default Re: How can I convert UNICODEwchar to ANSIC_char using STL.


recover wrote:
Quote:
#include <xxx>
int main()
{
const wchar* pwcHello=L"hello";
char* pcHello;
xxxxxx //do something using stl
cout<<pcHello<<endl;
}
>
=============out===========
hello
====end out========
>
I know in Windows,I can use WideCharToMultiByte to convert wchar_t Encoding
in Unicode to char Encoding in ANSI .
>
How can I do this using STL?
The facetious answer is to just take every other byte skipping the
first.

In order to do this with other strings though you need to understand
the character encodings in use.

You cannot convert an arbitrary string from Unicode to ASCII because
there are many more Unicode characters than there is room for in ASCII.
You can't always convert it to Shift_JIS and you can't always convert
it to TIS-620.

The simplest thing to do is to store tables of Unicode against other
encoding and go through that or to use a library like ICU
(International Components for Unicode) to do the conversions for you.

There aren't simple answers in any of this. The route that involves the
least learning is to just keep everything as Unicode strings - then you
only need to understand the different Unicode encodings. If you want to
convert to other narrow string formats then you need to learn about all
of these individually - or atleast learn a lot about the libraries that
help handle them.


K

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles