Registriert seit: 19. Jan 2009
Ort: Kirchlinteln (LK Verden)
1.053 Beiträge
Delphi 2009 Professional
|
AW: HTTP.Get/Post - Umlaute anzeigen
12. Nov 2019, 18:13
Lag hier irgendwo rum:
Delphi-Quellcode:
function JSONUnescape( const JSON: string): WideString;
var
i: Integer;
InSequence: Boolean;
UTF16Chars: Byte;
UTF16Data: Word;
const
Hex = ' 0123456789abcdef';
begin
Result := ' ';
InSequence := False;
UTF16Data := 0;
UTF16Chars := 0;
for i := 1 to Length(JSON) do
if InSequence then
begin
case Ord(JSON[i]) of
$75: begin
UTF16Data := 0;
UTF16Chars := 4;
end;
$62: Result := Result + #8;
$66: Result := Result + #12;
$6E: Result := Result + #10;
$72: Result := Result + #13;
$74: Result := Result + #9;
else if UTF16Chars > 0 then
begin
UTF16Data := UTF16Data shl 4 + Pos(Lowercase(JSON[i]), Hex) - 1;
dec(UTF16Chars);
if UTF16Chars = 0 then
begin
Result := Result + WideChar(UTF16Data);
InSequence := False;
end;
end
else
Result := Result + JSON[i];
end;
end
else
if JSON[i] = ' \' then
InSequence := True
else
Result := Result + JSON[i];
end;
Janni 2005 PE, 2009 PA, XE2 PA
Geändert von Redeemer (12. Nov 2019 um 18:15 Uhr)
|