简体   繁体   中英

UTF-8 to UTF-16 API wrapper libraries for Windows?

Is there any wrapper library out there that mimics the Windows "ANSI" function names (eg CreateFileA ), assumes the inputs are in UTF-8, converts them to UTF-16, calls the UTF-16 version of the function (eg CreateFileW ), and converts the outputs back to UTF-8 for the program?

It would allow ASCII programs to use UTF-8 almost seamlessly.

Rather than wrapping the API functions, it's easier to wrap the strings in a conversion function. Then you'll be future-proof when the next version of Windows adds more API functions.

As others said, there are too many WinAPI functions to make such a library feasible. However one can hack it on the tool-chain level or using something like http://research.microsoft.com/en-us/projects/detours/ .

EDIT: Windows 10 added support for UTF-8 codepage in ANSI API .

There is this thing called WDL , it has some UTF-8 wrappers (win32_utf8). I have never tried it so I don't know how complete the support is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM