开发者

Mapping Windows-1252 encoding to UTF8 in C

开发者 https://www.devze.com 2023-03-06 07:16 出处:网络
How do you progra开发者_如何学Gommatically convert a C-string with encoding Windows-1252 (a.k.a. CP1252) to UTF8?On Windows? First call MultiByteToWideChar and then WideCharToMultiByte.

How do you progra开发者_如何学Gommatically convert a C-string with encoding Windows-1252 (a.k.a. CP1252) to UTF8?


On Windows? First call MultiByteToWideChar and then WideCharToMultiByte.

On a Mac or Linux: call iconv_open and then iconv as needed.

In general: incorporate the ICU4C library.


You need to use a code page conversion, which is language/paltform specific.

If you want to implement it: Windows-1252 on Wikipedia (there is a link to the conversion table)

Some solutions:

  • Windows: MultiByteToWideChar
  • python: decode()
  • Linux: libiconv (just one of the many)

etc...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号