unescape_unescape()函数以及JavaScript中的示例

unescape

If we have an encoded data which has been encoded using the escape() function, and we need the actual data, in such case – we use unescape() function. This is also a predefined function in JavaScript and returns decoded data which has been encoded using the escape() function.

如果我们有一个已使用escape()函数编码的编码数据,并且在这种情况下需要实际数据,则可以使用unescape()函数 。 这也是JavaScript中的预定义函数,它返回已使用escape()函数编码的已解码数据。

Example:

例:

<html>
<head>
<title>JavaScipt Example</title>
</head>

<body>
	<script>
		//Actual string
		str1 = "Hello world!";
		//encoded string
		str2 = escape(str1);
				
		document.write("Actual string is: " + str1);
		document.write("<br>");
		document.write("Encoded string is: " + str2);
		document.write("<br>");		
		//decoding the string
		str3 = unescape(str2);
		document.write("Decoded string is: " + str3);
		document.write("<br>");				

		//Actual string
		str1 = "email id: [email protected]";
		//encoded string
		str2 = escape(str1);
				
		document.write("Actual string is: " + str1);
		document.write("<br>");
		document.write("Encoded string is: " + str2);
		document.write("<br>");		
		//decoding the string
		str3 = unescape(str2);
		document.write("Decoded string is: " + str3);
		document.write("<br>");
	</script>
</body>
</html>

Output

输出量

Actual string is: Hello world!
Encoded string is: Hello%20world%21
Decoded string is: Hello world!
Actual string is: email id: [email protected]
Encoded string is: email%20id%3A%[email protected]
Decoded string is: email id: [email protected]


翻译自: https://www.includehelp.com/code-snippets/unescape-function-with-example-in-javascript.aspx

unescape

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值