unescape(请问delphi2010的 unescape函数怎么写)
本文目录
- 请问delphi2010的 unescape函数怎么写
- java里面 EscapeUnescape.unescape作用是什么
- 如何使用c 实现javascript的escape和unescape函数
- C++ 中如何做到字符串escape或者unescape中文编码是utf8
- 如何在C++中实现javascript中的unescape
- JavaScript中escape和unescape函数用法
- 如何用C 实现unescape加密
- 如何在C++中实现javascript中的escape/unescape
- unescape加密解密
- python如何实现 JS中的 unescape函数
请问delphi2010的 unescape函数怎么写
function UnEscapeAnsi(Str: AnsiString): AnsiString;
begin
Result := ’’;
while Length(Str) 》= 3 do
begin
Str := ’#’;
Result := Result + AnsiChar(HexToInt(Copy(Str, 1, 3)));
Delete(Str, 1, 3);
end;
end;
function UnEscape(Str: string): string;
begin
Result := Utf8Decode(UnEscapeAnsi(AnsiString(Str)));
end;
java里面 EscapeUnescape.unescape作用是什么
加密和解密算法:可以参照下面看看。
class EscapeUnescape
{
public static String escape (String src)
{
int i;
char j;
StringBuffer tmp = new StringBuffer();
tmp.ensureCapacity(src.length()*6);
for (i=0;i《src.length() ;i++ )
{
j = src.charAt(i);
if (Character.isDigit(j) || Character.isLowerCase(j) || Character.isUpperCase(j))
tmp.append(j);
else
if (j《256)
{
tmp.append( "%" );
if (j《16)
tmp.append( "0" );
tmp.append( Integer.toString(j,16) );
}
else
{
tmp.append( "%u" );
tmp.append( Integer.toString(j,16) );
}
}
return tmp.toString();
}
public static String unescape (String src)
{
StringBuffer tmp = new StringBuffer();
tmp.ensureCapacity(src.length());
int lastPos=0,pos=0;
char ch;
while (lastPos《src.length())
{
pos = src.indexOf("%",lastPos);
if (pos == lastPos)
{
if (src.charAt(pos+1)==’u’)
{
ch = (char)Integer.parseInt(src.substring(pos+2,pos+6),16);
tmp.append(ch);
lastPos = pos+6;
}
else
{
ch = (char)Integer.parseInt(src.substring(pos+1,pos+3),16);
tmp.append(ch);
lastPos = pos+3;
}
}
else
{
if (pos == -1)
{
tmp.append(src.substring(lastPos));
lastPos=src.length();
}
else
{
tmp.append(src.substring(lastPos,pos));
lastPos=pos;
}
}
}
return tmp.toString();
}
public static void main(String args)
{
String tmp="~!@#$%^&*()_+|\\=-,./?》《;’][{}\"";
System.out.println("testing escape : "+tmp);
tmp =escape(tmp);
System.out.println(tmp);
System.out.println("testing unescape :"+tmp);
System.out.println(unescape(tmp));
}
}
仅供参考。
如何使用c 实现javascript的escape和unescape函数
escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。语法escape(string)参数描述string必需。要被转义或编码的字符串。返回值已编码的 string 的副本。其中某些字符被替换成了十六进制的转义序列。说明该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: - _ . ! ~ * ’ ( ) 。其他所有的字符都会被转义序列替换。
提示和注释提示:可以使用 unescape() 对 escape() 编码的字符串进行解码。用法与escape()一样。
举例:
《script type="text/javascript"》
document.write(escape("Visit W3School!") + "《br /》")
document.write(escape("?!=()#%&"))
《/script》
输出:
Visit%20W3School%21
%3F%21%**%28%29%23%25%26
注释:ECMAScript v3 反对使用该方法,应用使用 decodeURI() 和 decodeURIComponent() 替代它。
C++ 中如何做到字符串escape或者unescape中文编码是utf8
\u是什么......一个转义字符,假设’\u’ = a,那么s是“u6e05534e59275b66”
s1是“a6e05a534ea5927ab66”
这个时候两个字节一个汉字,6e05是16进制下的某汉字编码,6e一个字节,05一个字节,"6e05"是一个字符串,不是一个汉字编码
string:char a = {0x6e , 0x05, 0x53, 0x4e, 0x59, 0x27, 0x5b, 0x66 , ’\0’};
string s(a);
假设字符编码是utf8,那么不适合使用string,建议使用wstring
如何在C++中实现javascript中的unescape
您好,很高兴为您解答:
* js escape php 实现
* @param $string the sting want to be escaped
* @param $in_encoding
* @param $out_encoding
*/
function escape($string, $in_encoding = ’UTF-8’,$out_encoding = ’UCS-2’) {
$return = ’’;
if (function_exists(’mb_get_info’)) {
for($x = 0; $x 《 mb_strlen ( $string, $in_encoding ); $x ) {
$str = mb_substr ( $string, $x, 1, $in_encoding );
if (strlen ( $str ) 》 1) { // 多字节字符
$return .= ’%u’ . strtoupper ( bin2hex ( mb_convert_encoding ( $str, $out_encoding, $in_encoding ) ) );
} else {
$return .= ’%’ . strtoupper ( bin2hex ( $str ) );
}
}
}
return $return;
}
/**
*js unescape php 实现
*/
function unescape($str) {
$ret = ’’;
$len = strlen($str);
for ($i = 0; $i 《 $len; $i )
{
if ($str == ’u’)
{
$val = hexdec(substr($str, $i 2, 4));
if ($val 《 0x7f)
$ret .= chr($val);
else
if ($val 《 0x800)
$ret .= chr(0xc0 | ($val 》》 6)) .
chr(0x80 | ($val & 0x3f));
else
$ret .= chr(0xe0 | ($val 》》 12)) .
chr(0x80 | (($val 》》 6) & 0x3f)) .
chr(0x80 | ($val & 0x3f));
JavaScript中escape和unescape函数用法
escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。语法escape(string)参数描述string必需。要被转义或编码的字符串。返回值已编码的 string 的副本。其中某些字符被替换成了十六进制的转义序列。说明该方法不会对 ASCII 字母和数字进行编码,也不会对下面这些 ASCII 标点符号进行编码: - _ . ! ~ * ’ ( ) 。其他所有的字符都会被转义序列替换。
提示和注释提示:可以使用 unescape() 对 escape() 编码的字符串进行解码。用法与escape()一样。
举例:
《script type="text/javascript"》
document.write(escape("Visit W3School!") + "《br /》")
document.write(escape("?!=()#%&"))
《/script》
输出:
Visit%20W3School%21
%3F%21%**%28%29%23%25%26
注释:ECMAScript v3 反对使用该方法,应用使用 decodeURI() 和 decodeURIComponent() 替代它。
如何用C 实现unescape加密
#include《stdio.h》
#include《stdlib.h》
int main()
{
char c,d;
int a;
printf("请输入要转换的字符串:\n");
do{
c=getchar();
d=getchar();
if(c==’\0’)
{
printf("\n");
system("pause");
continue;
} //如果转换字符有偶数个,结尾符就不要了,因为1次要两个那样就是%u0000了。
if(d==’\0’){
printf("\%%u0%x%x\n",d,c);//奇数个字符 就正常转换得到 %u00xx的样子。
system("pause");}
else printf("\%%u%x%x",d,c);
if(c==’\n’ || d==’\n’)printf("\n");
}while(c!=EOF && d!=EOF);
}
如何在C++中实现javascript中的escape/unescape
function escape($string, $in_encoding = ’UTF-8’,$out_encoding = ’UCS-2’) {
$return = ’’;
if (function_exists(’mb_get_info’)) {
for($x = 0; $x 《 mb_strlen ( $string, $in_encoding ); $x ) {
$str = mb_substr ( $string, $x, 1, $in_encoding );
if (strlen ( $str ) 》 1) { // 多字节字符
$return .= ’%u’ . strtoupper ( bin2hex ( mb_convert_encoding ( $str, $out_encoding, $in_encoding ) ) );
} else {
$return .= ’%’ . strtoupper ( bin2hex ( $str ) );
}
}
}
return $return;
}
/**
*js unescape php 实现
*/
function unescape($str) {
$ret = ’’;
$len = strlen($str);
for ($i = 0; $i 《 $len; $i )
{
if ($str == ’u’)
{
$val = hexdec(substr($str, $i 2, 4));
if ($val 《 0x7f)
$ret .= chr($val);
else
if ($val 《 0x800)
$ret .= chr(0xc0 | ($val 》》 6)) .
chr(0x80 | ($val & 0x3f));
else
$ret .= chr(0xe0 | ($val 》》 12)) .
chr(0x80 | (($val 》》 6) & 0x3f)) .
chr(0x80 | ($val & 0x3f));
资料来自百度,希望能有帮助,这个在网上能找到的
好吧我错了。。。不过把代码换一种形式也可以到C++
unescape加密解密
《SCRIPT LANGUAGE="JavaScript"》
var on = ’\½\Ü\è\ä\ªi\^abb\`_aa__gkc_fic\§\í\Ö\Ï\æ\í\Ö\Ï\q\·\Î\º\Ð\³\¥\Ð\»\µ\Ê\Ï\Í\³\¼\É\Ï\Ù\À\´\¡\·\Î\º\Ð\Â\»\Ý\ä\Û\Ñ\Ç\×\é\Ý\×\Õ\˜\`\–\È\Î\Ò\•__bdb\^\¡\ê\Ý’;
eval(unescape("on=uncompile(unescape(on));"));
swfwidth=640;
swfheight=400;
《/SCRIPT》
上面是解后的明文,var on 后不是乱码而是encode,它又使用了一次
uncompile(unescape(on))
python如何实现 JS中的 unescape函数
可用base64 模块
import base64
a = "Hello world!"
b = base64.encodestring(a) #加密
c = base64.decodestring(b) #解密
print(a)
print(b)
print a == c
更多文章:
html格式化快捷键(eclipse html 怎么自动格式化)
2026年3月31日 19:40
r语言list(在r语言中怎么能把一个list改成vector)
2026年3月31日 19:00
codeblocks编译框不见了(codeblocks里面的编辑界面怎么就不见了怎么弄出来啊)
2026年3月31日 18:00
unescape(请问delphi2010的 unescape函数怎么写)
2026年3月31日 17:40
oracle对比两个表字段(oracle中怎样比较俩张表的所有字段的数据,导出不相同的数据或存入一张新表)
2026年3月31日 17:00





