How to convert CP1252 to UTF-8 inside Matlab

I'm pulling some text information from Excel spreadsheets into Matlab. Some of the special characters are encoded as CP1252.
How do I convert them into UTF-8 encoded special characters?

 Risposta accettata

as_unicode = native2unicode( uint8(TheVectorOfCP1252), 'CP1252');
as_utf8 = unicode2native( as_unicode, 'UTF-8');
as_utf8 will now be a uint8 array that can be fwrite()

3 Commenti

Many thanks!
What if the encoding is unknown? I just tried your code. Sometimes, the special characters are translated wrong. For example ' was translated to ÿ
If the encoding is unknown then you cannot know what the "correct" output is.

Accedi per commentare.

Più risposte (0)

Prodotti

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by