Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript chinese/japanese character decoding

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

like image 469
Chinchan Zu Avatar asked Aug 05 '26 21:08

Chinchan Zu


1 Answers

You can use decodeURIComponent to decode urlencoded strings like yours

decodeURIComponent('%E5%90%8D%E5%89%8D');
//result: '名前'
like image 121
Jani Hartikainen Avatar answered Aug 08 '26 11:08

Jani Hartikainen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!