'How to transform the word Gr\u008Egoire to it's normal form in Javascript?

Hope you are doing well! I have a list of french names with accents, but I receive them encoded like "Gr\u008Egoire", but I want to display the real word. Thank you in advance for your help!



Solution 1:[1]

The problem is the encoding of the e-acute letter (é). It should be \u00e9, since \u should introduce an UTF-16 encoded character, in which case you'd have nothing to do, putting this string in an element will display "Grégoire".

But \u008e is MAC Roman encoding.

You should try to find a converter from Mac Roman to UTF-8, I think there is one in node.js, or build your translation table from the Mac Roman encoding table.

See https://fr.wikipedia.org/wiki/MacRoman for the table.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2061037