\u8bf7\u52ff\u62cd\u6444!!\u5076\u50cf\u5185\u5e55 1280x720.EP01.\u6df1\u591c\u5267\u30d0\u30fc.\u5b57\u5e55\u7ec4.mkv
找到两种办法,
一种是执行js
我的JS脚本如下
function Uncode_utf8 (pValue) {return unescape(pValue.replace(/&#x/g,'%u').replace(/\\u/g,'%u').replace(/;/g,''));}
我用
..
CreateOleObject('ScriptControl');
..
script.Eval(Func)
执行不知道怎么传值给js
另外一种方法
在万一老师博客看到
function Unicode_str(text: string):string;
var
i,len: Integer;
ws: WideString;
begin
ws := '';
i := 1;
len := Length(text);
while i < len do
begin
ws := ws + Widechar(StrToInt('$' + Copy(text,i,4)));
i := i+4;
end;
Result := ws;
end;
但是这种不能解\u的。而且并没有区分英文字符,和半角标点。
5 个解决方案
#1
人工置顶
#2
SuperObject中Json用的就是这种编码方式.你可以找一个把里面的解码扒出来
#3
帮你写一个吧,也没几行代码.
const
v = '\u8bf7\u52ff\u62cd\u6444!!\u5076\u50cf\u5185\u5e55 1280x720.EP01.\u6df1\u591c\u5267\u30d0\u30fc.\u5b57\u5e55\u7ec4.mkv';
function UnicodeDecode(const value: Widestring): WideString;
var
P: PWideChar;
v: WideChar;
tmp : Widestring;
begin
P := PChar(value);
while P^ <> #0 do
begin
v := #0;
case P^ of
'\':
begin
Inc(P);
case P^ of
'\':
v := '\';
'u':
begin
tmp := Copy(p,2,4);
v := WideChar(StrToInt('$' + tmp));
Inc(p, 4);
end;
end;
end;
else
V := P^;
end;
Result := Result + v;
Inc(P);
end;
end;
procedure TForm10.Button1Click(Sender: TObject);
begin
Caption := UnicodeDecode(v);
end;
const
v = '\u8bf7\u52ff\u62cd\u6444!!\u5076\u50cf\u5185\u5e55 1280x720.EP01.\u6df1\u591c\u5267\u30d0\u30fc.\u5b57\u5e55\u7ec4.mkv';
function UnicodeDecode(const value: Widestring): WideString;
var
P: PWideChar;
v: WideChar;
tmp : Widestring;
begin
P := PChar(value);
while P^ <> #0 do
begin
v := #0;
case P^ of
'\':
begin
Inc(P);
case P^ of
'\':
v := '\';
'u':
begin
tmp := Copy(p,2,4);
v := WideChar(StrToInt('$' + tmp));
Inc(p, 4);
end;
end;
end;
else
V := P^;
end;
Result := Result + v;
Inc(P);
end;
end;
procedure TForm10.Button1Click(Sender: TObject);
begin
Caption := UnicodeDecode(v);
end;
#4
测试OK.
XE2。
非常感谢!
#5
刚才那个不完整,给你写了两个完整的函数.所有的转义符都处理了.
http://www.raysoftware.cn/?p=228
http://www.raysoftware.cn/?p=228
#1
人工置顶
#2
SuperObject中Json用的就是这种编码方式.你可以找一个把里面的解码扒出来
#3
帮你写一个吧,也没几行代码.
const
v = '\u8bf7\u52ff\u62cd\u6444!!\u5076\u50cf\u5185\u5e55 1280x720.EP01.\u6df1\u591c\u5267\u30d0\u30fc.\u5b57\u5e55\u7ec4.mkv';
function UnicodeDecode(const value: Widestring): WideString;
var
P: PWideChar;
v: WideChar;
tmp : Widestring;
begin
P := PChar(value);
while P^ <> #0 do
begin
v := #0;
case P^ of
'\':
begin
Inc(P);
case P^ of
'\':
v := '\';
'u':
begin
tmp := Copy(p,2,4);
v := WideChar(StrToInt('$' + tmp));
Inc(p, 4);
end;
end;
end;
else
V := P^;
end;
Result := Result + v;
Inc(P);
end;
end;
procedure TForm10.Button1Click(Sender: TObject);
begin
Caption := UnicodeDecode(v);
end;
const
v = '\u8bf7\u52ff\u62cd\u6444!!\u5076\u50cf\u5185\u5e55 1280x720.EP01.\u6df1\u591c\u5267\u30d0\u30fc.\u5b57\u5e55\u7ec4.mkv';
function UnicodeDecode(const value: Widestring): WideString;
var
P: PWideChar;
v: WideChar;
tmp : Widestring;
begin
P := PChar(value);
while P^ <> #0 do
begin
v := #0;
case P^ of
'\':
begin
Inc(P);
case P^ of
'\':
v := '\';
'u':
begin
tmp := Copy(p,2,4);
v := WideChar(StrToInt('$' + tmp));
Inc(p, 4);
end;
end;
end;
else
V := P^;
end;
Result := Result + v;
Inc(P);
end;
end;
procedure TForm10.Button1Click(Sender: TObject);
begin
Caption := UnicodeDecode(v);
end;
#4
测试OK.
XE2。
非常感谢!
#5
刚才那个不完整,给你写了两个完整的函数.所有的转义符都处理了.
http://www.raysoftware.cn/?p=228
http://www.raysoftware.cn/?p=228