Arthur
Arthur

Reputation: 31

special unicode symbol in javascript (AJAX)

I'm having a trouble with some special symbols in javascript, hope someone cal help me : )

First, I allow the user to send some text through a form, and I insert the text in a EUC-JP data base.

The second part consists in a display page where I get the text with AJAX, and show it in a simple alert when the data arrives to the javascript code.

The problem is when I use a symbol like ⑴ (is U+2474, from unicode). In this case, when the text is inserted in the data base, it is inserted as "& # 9 3 3 2 ;" (I wrote a blank to avoid the conversion in ⑴) In the second part, I use the js file and the php file that is called in the AJAX part. In the php file, I return the text gotten from the data base using UTF-8 encoding, like that.

PHP FILE: echo mb_convert_encoding(row['text'], "UTF-8","EUCJP-WIN");

But when i display the text in a javascript alert, it displays "& # 9 3 3 2 ;"

I tried a lot of stuff, and i couldn't make it display & # 9 3 3 2;, can anyone help me please?

Thanks! : )

Upvotes: 1

Views: 654

Answers (1)

Matty F
Matty F

Reputation: 3783

Here is the difference:

alert('\u2474'); => ⑴
alert('\\u2474'); => \u2474

You need to escape the leading backslash by adding another backslash :)

Upvotes: 1

Related Questions