By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,042 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,042 IT Pros & Developers. It's quick & easy.

Reading unicode (utf-16 le) using wifstream

P: n/a
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. :(

/*
- subgroup {"?yH} std::basic_string<wchar_t,std::char_traits<wchar_t >,std::allocator<wchar_t>
+ 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<wchar_t,std::char_traits<wchar_t >,std::allocator<wchar_t>::_Bxty

- _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

*/

Mar 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Mar 21 '06 #2

P: n/a
Thx man, i'll check those links and post my results.

Mar 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.