Reputation: 423
I'm receiving the following string (Artist name - Song name) with unreadable characters from a JSON file:
Las Crème Brûlée - Quiéreme Siempre
Is there any way to convert these and other unreadable characters into a proper string with special characters via a Javascript or jQuery function?
In the example provided, this is how the string should be read:
Las Crème Brûlée - Quiéreme Siempre
Project background
The string is read from a JSON file generated from an Icecast mountpoint. For those unfamiliar, Icecast is a streaming server and, for some reason, the streaming software (SAM Broadcaster) is sending the song names without the characters properly encoded.
Upvotes: 2
Views: 457
Reputation: 2422
Escaping the string will generate a UTF-8 encoded string and then turn it back into a JavaScript UCS-2 string with decodeURIComponent()
.
console.log(decodeURIComponent(escape('Las Crème Brûlée - Quiéreme Siempre')));
Upvotes: 3