[Lazarus] Mac (or other BigEndian machine) users needed to test new Utf8StringOfChar code

Hans-Peter Diettrich DrDiettrich1 at aol.com
Tue Sep 17 02:03:17 CEST 2013


Bart schrieb:

>> Did you also test the simpler approach, replicating the pattern in one
>> loop? It's independent of endianness, and can boil down to a single
>> machine instruction (x86: REP MOVS).
> 
> It would be repeating either 2,3, or 4-bytes each time.
> How would you code that?

I would not care.

> function Utf8StringOfChar(AUtf8Char: Utf8String; N: Integer): Utf8String;
> var
>   UCharLen, i,nb: Integer;
>   PC: PChar;
> begin
>   Result := '';
>   UCharLen := Length(AUtf8Char);
     nb := N*UCharLen;
     if nb <= 0 then exit;
>   //3:
       Result := AUtf8Char;
>       SetLength(Result, nb);
         PC := Result;
>       for i:=1 to nb-UCharLen do
>       begin
>         PC[UCharLen] := PC[0] inc(PC);
>       end;
> end;

DoDi





More information about the Lazarus mailing list