mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 16:09:23 +02:00
* fixed CharLengthPChar() implementation and added comment (from Windows
sysutils unit) about what it does (this routine currently isn't used anywhere, so the bugs didn't really have any impact) git-svn-id: trunk@29378 -
This commit is contained in:
parent
95b005cab7
commit
b0c7415f3a
@ -809,6 +809,10 @@ function CompareTextWideString(const s1, s2 : WideString): PtrInt;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ return value: number of code points in the string. Whenever an invalid
|
||||||
|
code point is encountered, all characters part of this invalid code point
|
||||||
|
are considered to form one "character" and the next character is
|
||||||
|
considered to be the start of a new (possibly also invalid) code point }
|
||||||
function CharLengthPChar(const Str: PChar): PtrInt;
|
function CharLengthPChar(const Str: PChar): PtrInt;
|
||||||
var
|
var
|
||||||
nextlen: ptrint;
|
nextlen: ptrint;
|
||||||
@ -824,14 +828,14 @@ function CharLengthPChar(const Str: PChar): PtrInt;
|
|||||||
{$endif not beos}
|
{$endif not beos}
|
||||||
repeat
|
repeat
|
||||||
{$ifdef beos}
|
{$ifdef beos}
|
||||||
nextlen:=ptrint(mblen(str,MB_CUR_MAX));
|
nextlen:=ptrint(mblen(s,MB_CUR_MAX));
|
||||||
{$else beos}
|
{$else beos}
|
||||||
nextlen:=ptrint(mbrlen(str,MB_CUR_MAX,@mbstate));
|
nextlen:=ptrint(mbrlen(s,MB_CUR_MAX,@mbstate));
|
||||||
{$endif beos}
|
{$endif beos}
|
||||||
{ skip invalid/incomplete sequences }
|
{ skip invalid/incomplete sequences }
|
||||||
if (nextlen<0) then
|
if (nextlen<0) then
|
||||||
nextlen:=1;
|
nextlen:=1;
|
||||||
inc(result,nextlen);
|
inc(result,1);
|
||||||
inc(s,nextlen);
|
inc(s,nextlen);
|
||||||
until (nextlen=0);
|
until (nextlen=0);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user