how do I read unicode text files?

B

Boris

Hi,
I saved a notepad textfile with "unicode" coding and tried this code:

std::wifstream
in( "test.txt" );
assert( in );
in.unsetf( std::wios::skipws );

std::wstring
w = std::wstring( std::istream_iterator< wchar_t, wchar_t >( in ),
std::istream_iterator< wchar_t, wchar_t >());
std::wcout << w << std::endl;

Unfortunatly I get

 ■t e s t u n i c o d e

instead of

test unicode

I like to get rid of the redundant spaces and the control charakter at the
beginning. When I do this for "ANSI" encoding, everything is ok.
Can anybody help?

Thanks,

Boris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top