1
votes

I am developing the application that uses MultiByteToWideChar() and WideCharToMultiByte() functions to convert UTF-8 to UTF-16 and vice versa. The intention of my work is to port that application from Windows to Linux. Since those functions are used widely throughout the code I would like to minimize the code changes afterwards. Unfortunately I have a limitation - cannot use open source libraries like Wine so I’m basically looking for a good algorithm for conversion of multi byte UTF-8 string to UTF-16 wide character string (and vice versa) that will work on 32\64-bit Linux and use only standard Linux C library.

Could someone recommend me the appropriate algorithm or standard implementation that I can use.

1
You should look at wchar.h in the standard C library, there is a bunch of functions to convert between multibyte/wide C strings. - Dmytro Sirenko
But they do not perform UTF conversion itself. I have to find at least some generic algorithm for conversion. - yetanotherguy

1 Answers

-3
votes

UTF-8 and UTF-16 are very simple encodings that are easy to implement by hand, you don't even need to use any libraries if those are the only two encodings you are worried about.