Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm developing a dependent select script using jQuery, PHP and JSON as the response.

Everything goes well except for using special characters like French ones (é , è , à...)

if I pre-encode them like (é , è , à) (Here I'm using spaces between the ampersand and the rest of the word to prevent auto encoding in my question) it works but when rendered with jquery the characters are not converted to what they should look like (é...), instead they are shown as is (é)

If I write them like (é) and don't pre-encode them the full value in this array entry is not shown.

What should I do here?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
422 views
Welcome To Ask or Share your Answers For Others

1 Answer

If I write them like (é) and don't pre-encode them the full value in this array entry is not shown.

What should I do here?

In JSON you do not HTML-encode values. You send them literally (é) and set set Content-Type correctly:

header('Content-Type: application/json; Charset=UTF-8');

Declare the encoding your data is in, of course.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...