![]() |
String(ansi) to Url-Encoded String
gugux,
ich bin auf der suche nach einer procedure oder einer möglichkeit besser gesagt um einen ansistring in einen url-encoded string umzuwandeln. Nicht die buchstaben nur also die sonderzeichen. zb. whitespace = + oder so Danke |
Re: String(ansi) to Url-Encoded String
Richtig: whitespace = +
Die anderen sind die Hexadezimalcodes z.B. das Zeichen "&" ist dann "%26" Folgender Code ist die Umkehrung deiner Frage:
Delphi-Quellcode:
Hoffe das hilft Dir.
// Converts a URLencoded string to a normal string
Function DecodeURL(Instr: String): String; Var S: String; X: Integer; C,N1,N2: Char; Begin If Instr='' then exit; S := ''; TempURL := Instr; // Copy URLencoded string Index := 1; // Reset string index Repeat C := GetURLchar; // Get next character If C='%' then // If it's a hex esc char Begin N1 := GetURLchar; // Get first digit N2 := GetURLchar; // Get second digit X := (Hex2Int(N1)*16)+Hex2Int(N2); // Convert to integer S := S+Chr(X); // Add character end else If C='+' then // If + then convert to space S := S+' ' else S := S+C; // Just add character Until C=' '; // Until no more in string Result := S; end; |
Re: String(ansi) to Url-Encoded String
Hallo,
das hast Du gesucht, oder :wink:
Delphi-Quellcode:
Function URLEncode(Value : String) : String;
Var I : Integer; Begin Result := ''; For I := 1 To Length(Value) Do Begin If Pos(UpperCase(Value[I]), ValidURLChars) > 0 Then Result := Result + Value[I] Else Begin If Value[I] = ' ' Then Result := Result + '+' Else Begin Result := Result + '%'; Result := Result + IntToHex(Byte(Value[I]), 2); End; End; End; End; |
Re: String(ansi) to Url-Encoded String
das 2.
aber da klebt er bei: ValidURLChars als undef bezeichner. muss ich da noch was in die uses eintragen? |
Re: String(ansi) to Url-Encoded String
was vergessen :oops:
Delphi-Quellcode:
Const ValidURLChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$-_@.&+-!*"''(),;/#?:';
|
Re: String(ansi) to Url-Encoded String
irgendwie macht es nicht das, wie's soll.
hab jetzt test := URLEncode(test); macht er nicht |
Re: String(ansi) to Url-Encoded String
Warum die ganze Arbeit?
![]() Zitat:
|
Re: String(ansi) to Url-Encoded String
Zitat:
|
Re: String(ansi) to Url-Encoded String
Zitat:
Bei mir klappt es, hab es gerade nochmal getestet. Aus 'http://www.google.de/search?hl=de&q=Delphi&meta=' wird 'http://www.google.de/search?hl%3Dde&q%3DDelphi&meta%3D' |
Re: String(ansi) to Url-Encoded String
hab ich doch. ist relativ komplex und nicht gpl.
bei mir siehts so aus: text := urlencode(memo1.text); memo1.text := text ; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:37 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz