Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,094
    • Issues 2,094
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 7
    • Merge requests 7
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar

We will soon be undergoing scheduled maintenance to our database layer. We expect GitLab.com to be unavailable for up to 2 hours starting from 2022-07-02 06:00 UTC. Please note that any CI jobs that start before the maintenance window but complete during the window period will fail and may need to be started again.

  • FPC
  • Lazarus
  • LazarusLazarus
  • Issues
  • #39501
Closed
Open
Created Dec 05, 2021 by Martin@martin_frbOwner

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.
Assignee
Assign to
Time tracking