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.
-
Your solution is only going to be as portable as the libraries you use (ICU is very portable, for example). If you insist on using no libraries at all, you should be prepared to copy lookup tables with thousands and thousands of entries.Arthur Reutenauer– Arthur Reutenauer2009年11月16日 11:19:06 +00:00Commented Nov 16, 2009 at 11:19
-
utf-16 and utf-8 are both different encodings of the same underlying numbers, so its quite possible to do this transformation in a very small platform independent way. For everything else, lots of character encodings only make sense or are defined on a single platform, this is one of those places where it makes sense to have a file - or files - with platform specific character set transformation routines.Chris Becke– Chris Becke2009年11月16日 11:56:38 +00:00Commented Nov 16, 2009 at 11:56
-
Hello priyank Regard Anirudha Gupta anirudhagupta.blogspot.comAnirudha Gupta– Anirudha Gupta2009年11月17日 10:55:37 +00:00Commented Nov 17, 2009 at 10:55
-
I am anirudha you can contact me @ anirudhagupta.blogspot.com/2009/11/…. but don't disclosed your mail address in commentAnirudha Gupta– Anirudha Gupta2009年11月17日 11:25:18 +00:00Commented Nov 17, 2009 at 11:25
3 Answers 3
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.
3 Comments
The Boost Serialization library contains a UTF-8 codecvt facet.
Comments
You can use libiconv (Google it ), it supports many encodings.