r.z. wrote:
I know I'm missing something and maybe someone will shed some light on this:
I just wan't to read some info from a text file I create in Notepad. What
should I use:
basic_ifstream<char, char_traits<char>file(filepath)
or
basic_ifstream<wchar_t, char_traits<wchar_t>file(filepath)
I surround all strings with TEXT macro in my program but how to know what is
the type data stored in an external file ?
Open the file, read a few bytes, try to "sniff" it. UTF-16, for
example, will give you a nul-character for every two characters most of
the time. UTF-8 might give you a byte-order mark (but might not), etc.
There's no magic way to do this, but if you look at such open-source
projects as GNU file, Xerces-C, etc. which all deal with the same kind
of problems, the methods are basically always the same.
rlc