问题描述
我有一个Web服务可以从各种客户端接收数据。其中一些发送使用escape()编码的数据,而其他的则使用encodeURIComponent()。有没有办法检测用于转义数据的编码?鼓励您的客户端使用encodeURIComponent()。请参阅此页面以获取解释:比较escape(),encodeURI()和encodeURIComponent()一>。如果你真的想要弄清楚一些东西是如何被编码的,你可以尝试寻找一些转义()和encodeURI()不被编码的字符。
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 a way to detect the encoding used to escape the data?
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.
这篇关于如何检测字符串是否使用escape()或encodeURIComponent()进行编码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!