Reading unicode (utf-16 le) using wifstream

Discussion in 'C++' started by anubis, Mar 21, 2006.

  1. anubis

    anubis Guest

    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

    */
     
    anubis, Mar 21, 2006
    #1
    1. Advertising

  2. 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
     
    Tilman Kuepper, Mar 21, 2006
    #2
    1. Advertising

  3. anubis

    anubis Guest

    Thx man, i'll check those links and post my results.
     
    anubis, Mar 21, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Hetland

    ifstream and wifstream - combined

    Ben Hetland, Sep 20, 2005, in forum: C++
    Replies:
    0
    Views:
    679
    Ben Hetland
    Sep 20, 2005
  2. toton

    wstring & wifstream

    toton, Sep 29, 2006, in forum: C++
    Replies:
    9
    Views:
    2,582
    =?iso-8859-1?q?Kirit_S=E6lensminde?=
    Oct 2, 2006
  3. koara

    wifstream & locale

    koara, Feb 5, 2008, in forum: C++
    Replies:
    2
    Views:
    803
    koara
    Feb 6, 2008
  4. Ioannis Vranos

    wifstream/wofstream names

    Ioannis Vranos, Sep 30, 2008, in forum: C++
    Replies:
    1
    Views:
    732
  5. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,030
    Grzegorz ¦liwiñski
    Jan 19, 2011
Loading...

Share This Page