[Lazarus] UTF8String and UTF8Delete

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Dec 11 14:59:29 CET 2015


On Fri, 11 Dec 2015 14:32:14 +0200
Juha Manninen <juha.manninen62 at gmail.com> wrote:

> On Fri, Dec 11, 2015 at 2:12 PM, Mattias Gaertner
> <nc-gaertnma at netcologne.de> wrote:
> > On Fri, 11 Dec 2015 08:05:12 +0100
> > Sven Barth <pascaldragon at googlemail.com> wrote:
> >> Also I doubt that you can do this for var parameters...
> >
> > FPC 3.0 eats it without a hint.
> 
> It does not work though. Interesting.
> Using the new default UTF-8 system for LCL apps and FPC 3.0 on Linux,
> this works :
> 
> var
>   uStr1, uStr2: String;
> begin
>   uStr1 := 'йäй';
>   uStr2 := uStr1;
>   UTF8Delete(uStr2,1,1);
>   ShowMessage('Original: ' + uStr1 + ',   Deleted: ' + uStr2);
> 
> but this shows garbage :
> 
> var
>   uStr1, uStr2: UTF8String;
> begin
>   uStr1 := 'йäй'; 

The above literal requires {$codepage UTF8}.

>   uStr2 := uStr1;
>   UTF8Delete(AnsiString(Pointer(uStr2)),1,1);
>   ShowMessage('Original: ' + uStr1 + ',   Deleted: ' + uStr2);

Works here.
Also on Windows.
 
> Changing the last CharCount parameter for UTF8Delete makes no difference.

Works here.

 
> I was planning to add overloaded versions for procedures taking var
> parameters in LazUTF8. Copy/pasting code may be the only way to go.

Mattias




More information about the Lazarus mailing list