Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi UTF8 Codierung? (https://www.delphipraxis.net/76411-utf8-codierung.html)

API 4. Sep 2006 08:13


UTF8 Codierung?
 
Möchte 'unm%C3%B6glich' in eine "leserliche" Form bringen. (-> 'unmöglich' )

Delphi-Quellcode:
Utf8ToAnsi('unm%C3%B6glich')
funktioniert nicht.

Welche Funktion kann ich dafür verwenden?

Auch probiert: HTTPDecode. Geht aber auch nicht.

generic 4. Sep 2006 08:46

Re: UTF8 Codierung?
 
dein string ist url encodiert

Delphi-Quellcode:
 caption:=UTF8Decode( TIdURI.URLDecode('unm%C3%B6glich') );




edit: codetags

API 4. Sep 2006 09:08

Re: UTF8 Codierung?
 
Mein TIDURL kenn leider die URLDecode nicht. (alte indy version)

wenn ich's so mache, gib't eine AV:

Delphi-Quellcode:
function URLDecode(ASrc: string): string;
var
  i: integer;
  ESC: string[2];
  CharCode: integer;
begin
  Result := ''; {Do not Localize}
  i := 1;
  while i <= Length(ASrc) do begin
    if ASrc[i] <> '%' then begin {do not localize}
      Result := Result + ASrc[i]
    end else begin
      Inc(i); // skip the % char
      ESC := Copy(ASrc, i, 2); // Copy the escape code
      Inc(i, 1); // Then skip it.
      try
        CharCode := StrToInt('$' + ESC); {do not localize}
        Result := Result + Char(CharCode);
      except end;
    end;
    Inc(i);
  end;
end;
UTF8Decode(URLDecode('unm%C3%B6glich'))

API 4. Sep 2006 09:12

Re: UTF8 Codierung?
 
hat jetzt doch funktioniert..(Habe einen rekursiven Aufruf gemacht...)


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:38 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz