[Lazarus] UTF8String and UTF8Delete

Juha Manninen juha.manninen62 at gmail.com
Fri Dec 11 13:32:14 CET 2015


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 := 'йäй';
  uStr2 := uStr1;
  UTF8Delete(AnsiString(Pointer(uStr2)),1,1);
  ShowMessage('Original: ' + uStr1 + ',   Deleted: ' + uStr2);

Changing the last CharCount parameter for UTF8Delete makes no difference.

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

Juha




More information about the Lazarus mailing list