Reading unicode (utf-16 le) using wifstream

A

anubis

Heay, i've got this problem:

http://rafb.net/paste/results/lpNgbn49.html

i'm using wifstream to read utf-16 file and i've got this problem, that
each byte is read into seperate char while little-endian uses at least
2 bytes for one sign.

the code of method is in the above letter, also with the problem i'm
attaching below:
i've googled and browsed documentation, but can't make it out by my
own. :(

/*
+ std::_String_val<wchar_t,std::allocator<wchar_t> > {_Alval={...}
} std::_String_val<wchar_t,std::allocator<wchar_t> >
- _Bx {_Buf=0x0012f340 "쀰7H" _Ptr=0x0037c030 "þÿH"
} std::basic_string said:
- _Buf 0x0012f340 "쀰7H" wchar_t [8]
[0] 49200 '쀰' wchar_t
[1] 55 '7' wchar_t
[2] 72 'H' wchar_t
[3] 0 wchar_t
[4] 101 'e' wchar_t
[5] 0 wchar_t
[6] 108 'l' wchar_t
[7] 0 wchar_t
- _Ptr 0x0037c030 "þÿH" wchar_t *
254 'þ' wchar_t
_Mysize 12 unsigned int
_Myres 15 unsigned int

*/
 
T

Tilman Kuepper

Hi "Anubis",
i'm using wifstream to read utf-16 file and i've got this
problem, that each byte is read into seperate char while
little-endian uses at least 2 bytes for one sign.

PJ Plauger wrote a pair of columns in the April and May 1999
editions of the C/C++ Users Journal about reading/writing
Unicode files. He uses Codecvt facets to do the conversion.
You can find the source code on the cuj server:

http://www.cuj.com/code/

<OT>
If you are using Windows/Visual C++ the following link
might also be useful:
http://www.i18nguy.com/unicode/c-unicode.html
</OT>

Best regards,
Tilman
 

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

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top