Zitat von
IceTube:
^ich muss noch die Sonderzeichen übersetzen bei dir ist gemeint "München"...
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;