javascriptcunicodeutf-8gb2312

How to convert UNICODE / UTF-8 to GB2312 in C


I'm searching for a method to convert a two Byte UNICODE or a variable (1-3 Byte) UTF-8 string to Chinese Simplified (GB2312). I found a lot of methods for php, Java, C# and Windows but nothing for standard "C".

Right now, my best solution is to translate this JavaScript example: https://gist.github.com/19317362/a1d8e40bfb6587463d4d

Thanks in advance!


Solution

  • As Remy Lebeau mentioned, I used the C-compatible library iconv.