Convert ISO-8859-1 strings to UTF-8 in C/C++

后端 未结 6 890
礼貌的吻别
礼貌的吻别 2020-12-05 05:27

You would think this would be readily available, but I\'m having a hard time finding a simple library function that will convert a C or C++ string from ISO-8859-1 coding to

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 05:31

    The Unicode folks have some tables that might help if faced with Windows 1252 instead of true ISO-8859-1. The definitive one seems to be this one which maps every code point in CP1252 to a code point in Unicode. Encoding the Unicode as UTF-8 is a straightforward exercise.

    It would not be difficult to parse that table directly and form a lookup table from it at compile time.

提交回复
热议问题