Javascript decodeURI(Component) malformed uri exception

后端 未结 2 1547
遥遥无期
遥遥无期 2021-02-02 07:03

I entered the following in Chrome\'s console:

decodeURIComponent(\'a%AFc\');

Instead of resulting to a0xAFc, it caused a URIError

2条回答
  •  故里飘歌
    2021-02-02 07:04

    %AF is not a character on his own but part of Unicode sequence (MACRON - %C2%AF).

    %AF wasn't produced by encodeURIComponent but something like escape, so it can be decoded by unescape.

    What you probably need is decodeURIComponent('%C2%AF')

提交回复
热议问题