zoukankan
html css js c++ java
URL编码反编码
<!
DOCTYPE html PUBLIC
"
-//W3C//DTD XHTML 1.0 Transitional//EN
"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"
>
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
<
head
>
<
meta http
-
equiv
=
"
Content-Type
"
content
=
"
text/html; charset=gb2312
"
/>
<
title
>
无标题文档
</
title
>
<
script type
=
"
text/javascript
"
>
function
doCode(deCode)
{
var
txt1
=
document.getElementById(
"
txt1
"
);
var
txt2
=
document.getElementById(
"
txt2
"
);
if
(deCode)
{
txt2.value
=
urlDecode(txt1.value);
}
else
{
txt2.value
=
urlEncode(txt1.value);
}
}
function
urlDecode(str)
{
if
(
"
undefined
"
==
typeof
decodeURIComponent)
{
return
unescape(str).replace(
/
\
+/
g, ' ').replace(
/%
2B
/
g,'
+
');
}
else
{
/**/
/*
just use my self decode script
*/
/**/
/*
return decodeURIComponent(str.replace(/\+/g, ' ').replace(/%2B/g,'+'));
*/
return
unescape(str).replace(
/
\
+/
g, ' ').replace(
/%
2B
/
g,'
+
');
}
}
function
urlEncode(str)
{
var
i,c,ret
=
""
,strSpecial
=
"
!\
"
#$
%&
'()
*+
,
/
:;
<=>?
@[\]
^
`
{
|
}
~%
"
;
for(i=0;i<str.length;i++)
{
c=str.charAt(i);
if(c==
"
"
)
ret+=
"
+
"
;
else if(strSpecial.indexOf(c)!=-1)
ret+=
"
%
"
+str.charCodeAt(i).toString(16);
else
ret+=c;
}
return ret;
};
</script>
</head>
<body>
<div id=
"
output
"
>
Source:<br />
<textarea name=
"
txt1
"
cols=
"
52
"
rows=
"
12
"
></textarea><br />
Destination:<br />
<textarea name=
"
txt2
"
cols=
"
52
"
rows=
"
12
"
></textarea><br />
<input name=
"
Decode
"
type=
"
button
"
value=
"
Decode
"
onclick=
"
doCode(
true
);
"
/>
<input name=
"
Encode
"
type=
"
button
"
value=
"
Encode
"
onclick=
"
doCode(
false
);
"
/>
</div>
</body>
</html>
查看全文
相关阅读:
一些使用Android设备调试功能的注意事项(挖职位)
Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste
HIbernate java.lang.AbstractMethodError: com.microsoft.jdbc.base.BaseDatabaseMetaData.supportsGetGeneratedKeys()Z
applicationContext.xml 配置
No setter found for property 'userDAO' in class 'com.ssh.service.impl.User1Service'
structs 源码示例
基于MyEclipse+9.0+++Tomcat+7.0的SSH+平台搭建
struts2错误:The Struts dispatcher cannot be found.
使用Struts2开发Java Web应用程序(目录)
MyEclipse中导入Spring 4.0源码
原文地址:https://www.cnblogs.com/afxcn/p/725916.html
最新文章
WINFORM 自定义开关按钮控件-
SpringMVC介绍之Validation
SpringMVC断言--Assert
Json解析工具Jackson(使用注解)--jackson框架自定义的一些json解析注解
表单中的日期 字符串和Javabean中的日期类型的属性自动转换
java NPE就是空指针异常,null pointer exception
spring mvc日期转换(前端到后端,后端到前端)
springMvc把client传过来一个String类型,转换为日期类型为例
@DateTimeFormat
@ResponseBody 返回json字符串的核心类是org.springframework.http.converter.json.MappingJacksonHttpMessageConverter,它使用了Jackson 这个开源的第三方类库。主要是以下两个jar包:jackson-core-asl-1.6.4.jar;jackson-mapper-asl-1.6.4.jar
热门文章
SpringMVC日期类型转换问题三大处理方法归纳
rac 10g 加入节点具体解释
Comprehensive learning path – Data Science in Python深入学习路径-使用python数据中学习
【SSH三框架】Struts2第六章的基础:他们拦截函数的定义
1054 在一个字符串中的排序
MongoDB每64位版本下载
CRT远程连接server字符输出乱码解决一例
该小组的七年之痒
sgu Flow construction
HDU 1015 Safecracker 解决问题的方法
Copyright © 2011-2022 走看看