> pls see belowed:
>
> vector < string > ary;
> fstream fs;
>
> copy(istream_iterator< string>(fs),
> istream_iterator< string >(),
> back_inserter(ary));
>
> copy(ary.begin(), ary.end(),
> ostream_iterator< string>(cout, L"\r\n"));
>
> read a text and display it.
> now, i want to change it, to read a Unicode-Text file.
> i tried to do...like this
>
> vector < wstring > ary;
> wfstream fs;
>
> copy(istream_iterator< wstring, wchar_t >(fs),
> istream_iterator< wstring, wchar_t >(),
> back_inserter(ary));
>
> DWORD dwBeg = GetTickCount();
> copy(ary.begin(), ary.end(),
> ostream_iterator< wstring, wchar_t >(wcout, L"\r\n"));
>
> but, the result was too bad, i trace it, i found the wfstream used
mbstowcs function to convert the data to wide character, but, the file had
been a Unicode file!
> how to do?
Depends on what you mean by a Unicode file. I suspect you want one of:
UTF-8
UCS-2BE
UCS-2LE
UTF-16BE
UTF-16LE
If so, then see our CoreX add-on library -- there's an online reference
manual for it
at our web site. It has all these conversions, and then some.
HTH,
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
A unicode text file has a marker at the start that you probably need
to detect before you try reading the strings. See the "Byte-order
Mark" topic in MSDN.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
See
http://groups.google.com/groups?threadm=3e1b5aea_1%40corp.newsgroups.com
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken