function TForm1.DecodeUnicodeString(const S: string): string;
var
buf: array[0..4] of Char;
i: Integer;
Ch, PvCh: Char;
US: string;
Str: string;
begin
Result := '';
ZeroMemory(@buf[0], SizeOf(buf));
i := 1;
while i < Length(S) do
begin
Ch := S[i];
if (Ch = 'u') and (i > 1) then
begin
PvCh := S[i-1];
if PvCh = '\' then
begin
US := Copy(S, i+3, 2) + Copy(S, i+1, 2);
HexToBin(PChar(US), buf, 2);
Str := WideCharToString(@buf[0]);
Result := Copy(Result, 1, Length(Result)-1); // drop "\"
Result := Result + Str;
Inc(i, 5);
Continue;
end;
end;
Inc(i, 1);
Result := Result + Ch;
end;
end;