Felipe Monteiro de Carvalho schreef:
Hello,

I am having a problem with string conversion from utf-8 to utf-16:

procedure TForm1.Button6Click(Sender: TObject);
var
 WideText: PWideChar;
 AText: string;
 Size: Integer;
begin
 AText := 'Meu longo texto iso-8859-1';
 Size := Utf8ToUnicode(nil, PChar(AText), 0);
 WideText := GetMem(Size);

This should be
  WideText := GetMem(Size*2);
because you get the number of characters, and the number of bytes 2* number of characters.

 Utf8ToUnicode(WideText, PChar(AText), Size);
 FreeMem(WideText);
end;

When I execute this procedure above, I will get an error on the end of
the program:


BTW: I didn't get an access violoation, probably I was just lucky.

I got one when I compiled with -gh.

Vincent
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to