Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

conversion to Unicode

rase
New Contributor I
205 Views
Could somebody be so kind and tell a newbie how to convert a string of single byte characters (char) to a string of Unicode characters (wchar) in a way that the characters with more than 7 bits (e. g. German Umlaute, French accents) are treated correctly?
0 Kudos
1 Solution
JenniferJ
Moderator
205 Views
6 Replies
rase
New Contributor I
205 Views
In the meantime I found a solution: the function btowc converts single characters to Unicode, including 8 bit characters. Does somebody know a better solution, for example for a whole string?
Judith_W_Intel
Employee
205 Views
Quoting - rase
In the meantime I found a solution: the function btowc converts single characters to Unicode, including 8 bit characters. Does somebody know a better solution, for example for a whole string?

Does mbtowc do what you want?
JenniferJ
Moderator
206 Views
dpeterc
Beginner
205 Views
I use "iconv" library for this purpose. It allows you to make arbitrary conversions from different source and destinantion encodings.
http://www.gnu.org/software/libiconv/
It is licensed as LGPL, so you can also use it in commercial products.
This library is standard on Linux, used by many programs. So if your platform is Linux, you can expect it to be already installed.
rase
New Contributor I
205 Views
Thanks a lot for your answers. Judith: the function does what I want, but I suspected that there are other solutions which were provided by the other contributors.
woleakande
Beginner
205 Views

Hi rase,

Which language do you prefer.

Reply