![]() ![]() (So, you could peek at the first two bytes, and if they match those, assume it is UTF16-LE.) In my experience, those two bytes at the start of a file that is supposed to be text, is quite reliable indicator that the file is UTF16-LE. Elsewhere it is the zero-width non-breaking space. You can ignore it if it is the first character in the file. Often the first character in the file is BOM, "byte-order mark", 0xFEFF. Return 0x10000 + ((code & 0x3FF) ) to handle the input. * the input sequence is not valid UTF16-LE. ![]() Return code /* Or abort input sequence ends prematurely */ Return code /* Or abort input sequence is not UTF16-LE */ ![]() Return lo /* Or abort input sequence ends prematurely */ Then you can use wint_t getwc_utf16le(FILE *const in) Include, set an UTF-8 locale ( setlocale(LC_ALL, "en_US.UTF-8") is fine), open the file or stream in byte-oriented mode ( handle=fopen(filename, "rb"), fwide(handle,-1), i.e. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |