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

Bart bartjunk64 at gmail.com
Tue Sep 17 10:48:51 CEST 2013


On 9/17/13, Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:

>> 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;
>

I would think that FiilWord and FillDWord is faster than that.
For 3-byte sequence I almost did the same as you.

More to the point: does it produce correct results on BigEndian.
Theory (as in: as far as I can see and "compute in my head") says yes,
but I would like confirmation (on my secons code example).

Bart




More information about the Lazarus mailing list