Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

unicode

winapi

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

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

like image 567
user541686 Avatar asked May 01 '12 04:05

user541686


2 Answers

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.

like image 177
Mark Ransom Avatar answered Oct 23 '22 03:10

Mark Ransom


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.

like image 24
Yakov Galka Avatar answered Oct 23 '22 02:10

Yakov Galka