How to detect if a string is encoded with escape() or encodeURIComponent()

后端 未结 5 1016
误落风尘
误落风尘 2020-12-31 11:48

I have a web service that receives data from various clients. Some of them sends the data encoded using escape(), while the others instead use encodeURIComponent(). Is there

5条回答
  •  Happy的楠姐
    2020-12-31 12:35

    Encourage your clients to use encodeURIComponent(). See this page for an explanation: Comparing escape(), encodeURI(), and encodeURIComponent(). If you really want to try to figure out exactly how something was encoded, you can try to look for some of the characters that escape() and encodeURI() do not encode.

提交回复
热议问题