Reputation: 918
I created a JSONP function on the server and returns a UTF-8 encoded json object like this
applyLocalization({"Name":"%E5%90%8D%E5%89%8D","Age":"%E5%B9%B4%E9%BD%A2"});
on my javascript on the client side, i want to convert the garbled part to their original state like
{"Name":"名前", "Age":"年齢"}
I tried $.parseJSON() but it doesnt work
Upvotes: 3
Views: 12728
Reputation: 1038740
You could use the decodeURIComponent
function. But you shouldn't be URL encoding your javascript strings. You should send them as UTF-8 strings as-is. Javascript is capable of understanding them.
Upvotes: 5
Reputation: 43243
You can use decodeURIComponent
to decode urlencoded strings like yours
decodeURIComponent('%E5%90%8D%E5%89%8D');
//result: '名前'
Upvotes: 9