Re: ifstream and unicode

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Andrew Jarvis wrote:
Dear All,

It seems that basic_ifstream<wchar_t> reads the file as char and
translates the input to wchar_t.

Is there a stream class that will read a file that contains unicode?

What you need is a codecvt facet. IIRC, the default codecvt facet used by
VC++ wifstream assumes that the file is UTF-8.

http://www.dinkumware.com/libDCorX.html

....includes a number of useful character conversion facets including the
trivial UTF-16 -> UTF-16 conversion that you're looking for.

-cd



.