I need an io file library that can give my program the utf-16 (little endian) interface, but can process files in other encodings, mainly ascii (input only), utf-8, utf-16, utf-32 / ucs4, including both small and large byte orders with bytes.
Looking around the only library I found was the ICU ustdio.h library.
I tried this, but I canβt even get it to work with a very simple piece of text, and in its use there is quite a lot of null documentation, but only the help page of the ICU file, in which there are no examples and very small details (for example, making UFILE from an existing FILE, it is safe to use other functions that accept FILE *? Along with several others ...).
Also, id is much more likely a C ++ library that can give me a wide-stream interface through a C-style interface ...
std::wstring str = L"Hello World in UTF-16!\nAnother line.\n"; UFILE *ufile = u_fopen("out2.txt", "w", 0, "utf-16"); u_file_write(str.c_str(), str.size(), ufile); u_fclose(ufile);
Output
Hello World in UTF-16!ΰ¨δζΈζΌηζ ζη ζ°ζ€ζΈζβΈΰ΄
hex
FF FE 48 00 65 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 72 00 6C 00 64 00 20 00 69 00 6E 00 20 00 55 00 54 00 46 00 2D 00 31 00 36 00 21 00 0D 0A 00 41 00 6E 00 6F 00 74 00 68 00 65 00 72 00 20 00 6C 00 69 00 6E 00 65 00 2E 00 0D 0A 00
EDIT: The correct output of the windows will look like this:
FF FE 48 00 65 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 72 00 6C 00 64 00 20 00 69 00 6E 00 20 00 55 00 54 00 46 00 2D 00 31 00 36 00 21 00 0D 00 0A 00 41 00 6E 00 6F 00 74 00 68 00 65 00 72 00 20 00 6C 00 69 00 6E 00 65 00 2E 00 0D 00 0A 00