Friday, 23 August 2013

How to read a text file having unicode codes in C++?

How to read a text file having unicode codes in C++?

If I initialize a string:
std::string unicode8String = "\u00C1 M\u00F3ti S\u00F3l";
and print using cout, then output is
Á Móti Sól.
But when I read same same string "\u00C1 M\u00F3ti S\u00F3l" from a text
file using ifstream and store it in a std::string, and print it, output is
\u00C1 M\u00F3ti S\u00F3l
but I want it to print Á Móti Sól. The text file I have : \u00C1 M\u00F3ti
S\u00F3l And I want my program to read it and print Á Móti Sól
Is there any method for the above conversion ?

No comments:

Post a Comment