[fpc-pascal] Problem with string conversion

Marco van de Voort marcov at stack.nl
Fri Oct 20 08:18:56 CEST 2006


> 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);
>   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:
> 
> External: Sigsegv
> 
> System_remove_from_list_fixed
> 
> any ideas?

Did you include cwstring as first unit in your project?



More information about the fpc-pascal mailing list