views:

140

answers:

4

How to convert string from one charset to another in C++ in a portable way? For example I want to convert to wstring to UTF-8 character array or . How to do this?

I am asking some standard way no chilkatsoft, wxWidgets, Qt. Its a plain C++ application. Though some simple class or methods will do the job.

A: 

I suppose this library may help you: http://www.chilkatsoft.com/charset-library.asp

dreikanter
And here is some more http://www.codeproject.com/KB/applications/utf_8_utility.aspx (exatly for UTF encodigs).
dreikanter
+3  A: 

The common repetoire for character sets is Unicode. Hence, you'd want a Unicode-oriented library. Frameworks like Qt and wxWidgets offer some of this functionality; ICU is more specific to Unicode text processing.

MSalters
I am asking in standard C++, you should know the baggage of wxWidgets or Qt.
Priyank Bolia
The implied prerequisite is: there is no functionality for conversions between character sets in c++.
Georg Fritzsche
Indeed. And the reason that there is "baggage" in those libraries is because there's so much possible with computers, most of which isn't standardized by ISO. One mans bagage is another mans essential function.
MSalters
+1  A: 

The Boost Serialization library contains a UTF-8 codecvt facet.

sth
+1  A: 

You can use libiconv (Google it ), it supports many encodings.

siri
how portable libiconv is? and is there any samples?
Priyank Bolia