Ken
Ken

Reputation: 31161

Mapping Windows-1252 encoding to UTF8 in C

How do you programmatically convert a C-string with encoding Windows-1252 (a.k.a. CP1252) to UTF8?

Upvotes: 2

Views: 2315

Answers (2)

teki
teki

Reputation: 2062

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:

etc...

Upvotes: 0

bmargulies
bmargulies

Reputation: 100013

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.

Upvotes: 1

Related Questions