Delphi中Unicode轉中文
阿新 • • 發佈:2017-07-28
copy char del let har str string nes ide Exit;
end;
top := Copy(inputstr, 1, index); // 取出 編碼字符前的 非 unic 編碼的字符,如數字
temp := Copy(inputstr, index + 1, 6); // 取出編碼,包括 \u,如\u4e3f
Delete(temp, 1, 2);
Delete(inputstr, 1, index + 6);
Result := Result + top + WideChar(StrToInt(‘$‘ + temp));
end;
end;
function UnicodeToChinese(inputstr: string): string;
var
i: Integer;
index: Integer;
temp, top, last: string;
begin
index := 1;
while index >= 0 do
begin
index := Pos(‘\u‘, inputstr) - 1;
if index < 0 then
begin
last := inputstr;
Result := Result + last;
end;
top := Copy(inputstr, 1, index); // 取出 編碼字符前的 非 unic 編碼的字符,如數字
temp := Copy(inputstr, index + 1, 6); // 取出編碼,包括 \u,如\u4e3f
Delete(temp, 1, 2);
Delete(inputstr, 1, index + 6);
Result := Result + top + WideChar(StrToInt(‘$‘ + temp));
end;
Delphi中Unicode轉中文