How to decode url-encoded string in javascript

后端 未结 2 671
名媛妹妹
名媛妹妹 2020-12-11 02:33

I use javascript / jquery to fill dom elements that contain umlauts:

var text1 = \"Unser platonisches Internetreich droht in die H%E4nde einer bewaffneten Mi         


        
2条回答
  •  悲哀的现实
    2020-12-11 03:04

    That is not UTF-8, that is percent encoding also known as url encoding.

    You can use decodeURIComponent() to convert it back before displaying it

    $("#quote1 span").html(decodeURIComponent(text1));

提交回复
热议问题