如何检测字符串是否使用escape()或encodeURIComponent()进行编码) [英] How to detect if a string is encoded with escape() or encodeURIComponent()

查看:164
本文介绍了如何检测字符串是否使用escape()或encodeURIComponent()进行编码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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()进行编码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆