Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

conversion to Unicode

rase
New Contributor I
529 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
6 Replies
rase
New Contributor I
529 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?
0 Kudos
Judith_W_Intel
Employee
529 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?
0 Kudos
JenniferJ
Moderator
530 Views
0 Kudos
dpeterc
Beginner
529 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.
0 Kudos
rase
New Contributor I
529 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.
0 Kudos
woleakande
Beginner
529 Views

Hi rase,

Which language do you prefer.

0 Kudos
Reply