![]() |
utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
hi leute ich habe ein problem mit dem utf8decode() irgendwie decodiert er keine großen umlaute ?
kann man das was machen zB
Delphi-Quellcode:
memo1.text := utf8decode('ÄÖÜ');
|
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Hi,
so wie es aussieht, übergibst du ANSI-kodierte Umlaute - utf8Encode() würde da mehr Sinn machen. Grüße vom marabu |
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Delphi-Quellcode:
function FromUTF8 (const S: String): WideString;
var a,b,c: char; i,j: Integer; begin i:=1; j:=1; SetLength(result,length(S)); while i<=length(S) do begin a:=S[i]; Inc(i); if byte(a)<$80 then begin result[j]:=wchar(a); Inc(j); continue; end; if i>length(S) then break; b:=S[i]; Inc(i); if (byte(a)<$E0) or (i>length(S)) then begin result[j]:=wchar(((byte(a) and $1F) shl 6) or (byte(b) and $3F)); Inc(j); continue; end; c:=S[i]; Inc(i); result[j]:=wchar(((byte(a) and $F) shl 12) or ((byte(b) and $3F) shl 6) or (byte(c) and $3F)); Inc(j); end; SetLength(result,j-1); end; {FromUTF8} //Beispiel procedure TForm1.Button1Click(Sender: TObject); begin Edit2.text:= FromUTF8(Edit1.text); end; |
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
also aus der db kommt es so Ã?Ã?Ã?Ã?Ã?Ã?Ã?
utfencode macht garnichts und utfdecode, decodiert nur kleine umlaute ? |
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
zu hathor, gleiches problem wie utf8decode, versucht mal nur ein großes Ö zu decoden !
|
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Hallo Peter,
bei mir funktioniert das alles einwandfrei mit der Konvertierung, dein Problem liegt woanders. Schau dir mal die Hexcodes an, die du aus der DB bekommst - am Besten du zeigst die auch mal hier. Freundliche Grüße |
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Zitat:
Welche DB in welcher Version verwendest du mit welche Zugriffskomponenten? |
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
okay leute, es lag an der soap übertragung zu delphi ! danke trotzdem !
|
Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:
Unicode-Zeichen größer als 127 werden in der UTF-8-Kodierung zu Byteketten der Länge zwei bis vier kodiert. |
AW: Re: utf8decode(ÄÄÖÜ) wieso macht er das nicht ?
Zitat:
Da die entsprechend angepasste Funktion auch für andere Nutzer interessant sein könnte, spiel ich mal wieder den Totengräber. Die Funktion konvertiert UTF-8 und CESU-8 nach UTF-16.
Delphi-Quellcode:
Laut deutscher Wikipedia muss die kürzeste mögliche Kodierung gewählt werden. Daher kann man annehmen, dass ein durch 4 Zeichen kodierter Codepunkt nicht in der BMP liegt, sodass man ihn über UTF-16-Surrogates kodieren muss.
function FromUTF8 (const S: String): WideString;
var a,b,c,d: char; i,j: Integer; k: Cardinal; begin i:=1; j:=1; SetLength(result,length(S)); while i<=length(S) do begin a:=S[i]; Inc(i); if byte(a)<$80 then begin result[j]:=widechar(a); Inc(j); continue; end; if i>length(S) then break; b:=S[i]; Inc(i); if (byte(a)<$E0) or (i>length(S)) then begin result[j]:=widechar(((byte(a) and $1F) shl 6) or (byte(b) and $3F)); Inc(j); continue; end; c:=S[i]; Inc(i); if (byte(a)<$F0) or (i>length(S)) then begin result[j]:=widechar(((byte(a) and $F) shl 12) or ((byte(b) and $3F) shl 6) or (byte(c) and $3F)); Inc(j); continue; end; d:=S[i]; Inc(i); k := ((byte(a) and $7) shl 18) or ((byte(b) and $3F) shl 12) or (byte(c) and $3F shl 6) or (byte(d) and $3F); result[j]:=widechar((k - $10000) shr 10 and $3FF or $D800); Inc(j); result[j]:=widechar(k and $3FF or $DC00); Inc(j); end; SetLength(result,j-1); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:43 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