> On Jul 3, 2023, at 11:36 AM, Mattias Gaertner via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> Useless array of.
> And it does not return the bytecount.

it's an open array so what's the problem?

> 
>> var
>>  i: Integer;
>>  byteCount: Integer;
>> begin
>>  // Number of bytes required to represent the Unicode scalar
>>  if unicodeScalar < $80 then
>>    byteCount := 1
>>  else if unicodeScalar < $800 then
>>    byteCount := 2
>>  else if unicodeScalar < $10000 then
>>    byteCount := 3
>>  else if unicodeScalar < $110000 then
>>    byteCount := 4
>>  else
>>    raise Exception.Create('Invalid Unicode scalar');
>> 
>>  // Extract the individual bytes using bitwise operations
>>  for i := byteCount - 1 downto 0 do
>>  begin
>>    bytes[i] := $80 or (unicodeScalar and $3F);
> 
> Wrong for byteCount=1

really? How so? 

ChatGPT is risky because it will give wrong information with perfect confidence 
and there's no way for the ignorant person to know.

Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to