C++ unicode file io

前端 未结 5 1457
广开言路
广开言路 2021-02-06 16:10

I need a file io library that can give my program a utf-16 (little endian) interface, but can handle files in other encodings, mainly ascii(input only), utf-8, utf-16, utf-32/uc

5条回答
  •  [愿得一人]
    2021-02-06 16:54

    I think the problems come from the 0D 0A 00 linebreaks. You could try if other linebreaks like \r\n or using LF or CR alone do work (best bet would be using \r, I suppose)

    EDIT: It seems 0D 00 0A 00 is what you want, so you can try

    std::wstring str = L"Hello World in UTF-16!\15\12Another line.\15\12";
    

提交回复
热议问题