wantime
asked on
Delphi utf8: save string to array
hi,
that's say there are two variable "buffer" and "s"
var buffer: array[0..127]of char;
s: string;
s := 'prüfen';
how do i save variable s to buffer as utf8 format?
thanks,
wantime
that's say there are two variable "buffer" and "s"
var buffer: array[0..127]of char;
s: string;
s := 'prüfen';
how do i save variable s to buffer as utf8 format?
thanks,
wantime
ASKER
thanks.
btw, what is different between
array[0..127] of Char
and
array[0..127] of AnsiChar
?
btw, what is different between
array[0..127] of Char
and
array[0..127] of AnsiChar
?
when using Delphi 2009 +, Char is WideChar
ASKER
if Char is WideChar, which change should be made in the solution? I know that the space of buffer will be doubled, but i have not yet found the way to resolve it, the output in delphi2009 is not 'prüfen' but some chinese symbol.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
procedure TForm1.Button1Click(Sender
var
S: UTF8String;
ar: array[0..127] of AnsiChar;
begin
S := 'prüfen';
FillChar(ar, SizeOf(ar), 0);
Move(Pointer(s)^, ar, Length(s) * SizeOf(Char));
ShowMessage(UTF8String(ar)
end;