views:

538

answers:

2

I'm trying to find converting UTF-32 text to/from any code page is possible using the Windows API alone. I cannot used CLR to do this task.

The Code page identifiers page at Microsoft at http://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspx lists UTF-32 as being available to only managed applicatiosn.

ConvertStringTo/FromUnicode fails when UTF-32 is used.

+1  A: 

With a bit of knowledge of Unicode you should be able to create a UTF32 to UTF16 converter without using any APIs.

All characters in the range U+0000 to U+FFFF can simply have the upper 16 bits removed.

Values in the range U+10000 to U+10FFFF can be converted into two 16-bit words, called surrogate pairs:

http://en.wikipedia.org/wiki/UTF-16#Encoding_of_characters_outside_the_BMP

Bing
The answer is that it you cannot use Window API for this. You need to do it yourself.Here is a link to a tested code for this, from unicode: http://www.unicode.org/Public/PROGRAMS/CVTUTF/
A: 

You can use the iconv library in Windows. It fully supports UTF-32 (big and little endian).

Remy Lebeau - TeamB
I don't want to use any external library for this. An alternative library is libICU
This you will have to write your own code to convert between UTF-16 and UTF-32. It is not difficult to do manually.
Remy Lebeau - TeamB