Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change encoding from UTF-8 to ISO-8859-2 in Javascript

I would like to change string encoding from UTF-8 to ISO-8859-2 in Javascript. How can I do it?

I need it because I've designed a widget. User just copies < script > tag from my site and puts it on his. This script creates div and puts into div widget contents with text.

If target website is in UTF-8 encoding - it works fine. But when it is in ISO-8859-2 than text that is encoded in UTF-8 is displayed on site with ISO-8859-2 and as a result I see trash.

like image 616
Tom Smykowski Avatar asked Nov 05 '22 17:11

Tom Smykowski


1 Answers

Instead of using e.g. "ĉ" in your JavaScript code, use Unicode escapes such as "\u0109".

like image 62
Ignacio Vazquez-Abrams Avatar answered Nov 12 '22 11:11

Ignacio Vazquez-Abrams