Andrew Robinson <arobinso...@cox.net>于2018年9月13日周四 上午12:21写道:
> No, it is not that simple at all unless you decide to natively support > UTF-16LE (BMP only) UNICODE. Microsoft and all their major vendors support > Windows and NTFS, both of which only natively support UTF-16LE (BMP only) > UNICODE. Any other desired encoding requires on-the-fly translations, > making UTF-16LE (BMP only) UNICODE support in Windows easy, simple, and > elegant, and anything else very difficult. > We don't need assume the OS support UTF-16 . We can make IUP use UTF-8 only. For most OS expert windows, UTF-8 can works well . and for Windows , we can convert UTF-8 strings into UTF-16LE string and call *W api only. UTF-16 to UTF-8 translation is easy and we can use a TLS (thread local storage) buffer to write a simple function like const wchar * UTF8toUTF16 (const char * utf8string); // The result would put into a TLS buffer for thread-safe. > Changing the compiler to UNICODE support will also change all the relevant > windows API calls from *A to *W, which could be a problem if you don't > understand how UNICODE *doesn't* work in other ways. For example, I don't > know if any compiler will automatically maps calls in the > crt.dll from *fopen to *_wfopen when UNICODE support is enabled. If it did, > you could > I don't recommend to use UNICODE macro in any case, just call *W API directly. And for fopen/_wfopen , I suggest define a wrapper function like FILE * iup_fopen(const char *utf8filename, const char *mode); We can also define a macro like this: // include stdio.h before fopen macro #include <stdio.h> #define fopen(filename, mode) iup_fopen(filename, mode) > Because almost all IDE's and source code files are only written in ASCII > or ANSI, translating strings can't be optimized. Since Microsoft is > dominant everywhere in the world, almost all compilers/IDEs support > Microsoft options like prefixing a literal string with an "L" to > translate the string into UTF-16LE (BMP only) UNICODE. But again, this > would not be necessary if IDE's and source code were able to support > UTF-16LE (BMP only) UNICODE instead of ASCII only. > > I prefer UTF-8 only in source code, and don't use L"string" . Utf-8 is the only right way to support multi-platform in my opinion, Microsoft made many mistakes in this problem , and we don't need repeat the mistakes again.
_______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users