mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 08:30:54 +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;
|
||||
|
||||
|
||||
{ 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;
|
||||
var
|
||||
nextlen: ptrint;
|
||||
@ -824,14 +828,14 @@ function CharLengthPChar(const Str: PChar): PtrInt;
|
||||
{$endif not beos}
|
||||
repeat
|
||||
{$ifdef beos}
|
||||
nextlen:=ptrint(mblen(str,MB_CUR_MAX));
|
||||
nextlen:=ptrint(mblen(s,MB_CUR_MAX));
|
||||
{$else beos}
|
||||
nextlen:=ptrint(mbrlen(str,MB_CUR_MAX,@mbstate));
|
||||
nextlen:=ptrint(mbrlen(s,MB_CUR_MAX,@mbstate));
|
||||
{$endif beos}
|
||||
{ skip invalid/incomplete sequences }
|
||||
if (nextlen<0) then
|
||||
nextlen:=1;
|
||||
inc(result,nextlen);
|
||||
inc(result,1);
|
||||
inc(s,nextlen);
|
||||
until (nextlen=0);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user