RangeCheck error in ConvertUTF8ToUTF16
- Lazarus/FPC Version: 2.3
The below will raise a range check error.
at line 3676
// to double wide char UTF-16 char
C:=C-$10000;
C will be 40197. C is Cardinal. Subtracting 65536 fails.
As a side note:
Name: ConvertUTF8ToUTF16 Params: SrcCharCount - Char count allocated in source string
It appears SrcCharCount
is really the byte-length. For a function that (by name) takes Utf8 as Source this should be made clear.
Yes, Src
is a PChar
, meaning the pascal type of 8bit-char. But its ambiguous.
program Project1;
{$mode objfpc}{$H+}
uses
LazUTF8
{ you can add units after this };
const
a: array[0..4] of char = (
#240, #139, #128, #172, #0
);
var
b: array[0..9] of WideChar;
l: SizeUInt;
begin
ConvertUTF8ToUTF16(@b, 9, @a,4, [toInvalidCharToSymbol], l);
end.