Autor Beitrag
TriphunEM
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Mi 30.03.05 16:04 
Hallo, ich habe mal eine Frage.

Gibt es Delphi direkt ne möglichkeit, eine String in HTML Code umzuwandeln??
Soll aber für alle zeichen funktionieren, also auch griechisch oder russisch und so.

Beispiel :

Wolkenkratzer -> & #119;& #111;& #108;& #107;& #101;& #110;& #107;& #114;& #97;& #116;& #122;& #101;& #114;

Das Leerzeichen zwischen & und # bitte wegdenken, kann es sonst nicht darstellen!


Danke???
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 30.03.05 16:06 
Schau dir mal Ord() an. ;)
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 30.03.05 16:16 
Genauer gesagt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function ConvertHTML(const aText: String): String;
var
I: Integer;
begin
Result := '';
for I := 0 to Length(aText) do Result := Result+'$#'+IntToStr(Ord(aText[I]))+';';
end;

;)

PS.: Hab jetzt mal n $ statt einem & genommen, weil Delphi damit anscheinen auch Probleme hat. Werd mal schaun ob ich das irgendwie noch hinbiegen kann. ;)
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 30.03.05 16:37 
Okay. Ich weiß woran's lag. Siehe hier. ;)

Also wenn du das ganze in einer MessageBox anzeigen willst musst du's so machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function ConvertHTML(const aText: String): String;
var
I: Integer;
begin
Result := '';
for I := 0 to Length(aText) do Result := Result+'&&#'+IntToStr(Ord(aText[I]))+';';
end;

Wenn du's dir in ner Memo anzeigen willst reicht es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function ConvertHTML(const aText: String): String;
var
I: Integer;
begin
Result := '';
for I := 0 to Length(aText) do Result := Result+'&#'+IntToStr(Ord(aText[I]))+';';
end;

;)
TriphunEM Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Mi 30.03.05 16:52 
hey danke für die schnelle antwort...aber so ganz ist das nicht das richtige...
es funzt zwar, aber mit

Zitat:
Кабелни


funktioniert es nicht.

Ergebnis dann : ????????

es muss auch mit ausländischen hinhauen! will ein converter schreiben, der normale zeichen in htmlcode umwandelt, kann auch sein das man das unicode nennt!!!
??
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Mi 30.03.05 17:05 
Vielleicht schaust du mal hier vorbei www.w3.org/Internati...s/tutorial-char-enc/, vor allem in Bezug auf das Encoding (Denglisch *entschuldig*) ist der Abschnitt One character set, multiple encodings zu empfehlen.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
TriphunEM Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Mi 30.03.05 17:45 
danke, aber so richtig hilft mir das ne weiter!

wie bekomm ich das nun hin??? Keiner eine Idee mit Quellcode?
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Mi 30.03.05 19:06 
Wie liegt denn dein String in Delphi vor?
Wenn du griechische Zeichen usw. benutzen willst, dann wandelst du ihm am besten erstmal in UTF-16 um (Suche in: Delphi-Forum, Delphi-Library UNICODE). Den Code für jedes Zeichen kriegst du dann mittels WideChar() (oder auch Odd(), bin nicht sicher ob das auch bei Unicode geht).
Nun kannst du die Zahlenwerte in die HTML-Schreibweise umwandeln. Wichtig: Im HTML-Dokument muss auch der richtige Zeichensatz angegeben werden. In meinem Fall also UTF-16.

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 30.03.05 23:33 
Hallo!

Wenn Du auch Unicode Komponenten benötigst dann schau mal hier vorbei: www.tntware.com/delphicontrols/unicode

Gruß
Tino