如何确定字符串是否已经过URL编码? [英] How to find out if string has already been URL encoded?

查看:148
本文介绍了如何确定字符串是否已经过URL编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查字符串是否已被编码?

How could I check if string has already been encoded?

例如,如果我编码 TEST == ,我得到 TEST%3D% 3D 。如果我再次编码最后一个字符串,我得到 TEST%253D%253D ,如果它已经编码,我必须知道...

For example, if I encode TEST==, I get TEST%3D%3D. If I again encode last string, I get TEST%253D%253D, I would have to know before doing that if it is already encoded...

我已保存编码参数,我需要搜索它们。我不知道输入参数,它们是什么 - 编码与否,所以我必须知道在搜索之前是否必须对它们进行编码或解码。

I have encoded parameters saved, and I need to search for them. I don't know for input parameters, what will they be - encoded or not, so I have to know if I have to encode or decode them before search.

推荐答案

解码,与原始进行比较。如果它确实不同,则对原始进行编码。如果没有差异,则不对原始编码进行编码。但它仍然没有说明新解码的版本是否仍未编码。这是一个很好的递归任务。

Decode, compare to original. If it does differ, original is encoded. If it doesn't differ, original isn't encoded. But still it says nothing about whether the newly decoded version isn't still encoded. A good task for recursion.

我希望你不能在urlencode中写一个quine,否则这个算法就会卡住。

I hope one can't write a quine in urlencode, or this algorithm would get stuck.

这篇关于如何确定字符串是否已经过URL编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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