mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 02:00:30 +01:00
codetools: readnextatom: read utf8 characters
git-svn-id: trunk@28973 -
This commit is contained in:
parent
8a0af40b89
commit
81af1a8a2c
@ -1858,6 +1858,29 @@ begin
|
||||
end else
|
||||
// round bracket open
|
||||
inc(Src);
|
||||
#192..#255:
|
||||
begin
|
||||
// read UTF8 character
|
||||
inc(Src);
|
||||
if ((ord(c1) and %11100000) = %11000000) then begin
|
||||
// could be 2 byte character
|
||||
if (ord(Src[0]) and %11000000) = %10000000 then
|
||||
inc(Src);
|
||||
end
|
||||
else if ((ord(c1) and %11110000) = %11100000) then begin
|
||||
// could be 3 byte character
|
||||
if ((ord(Src[0]) and %11000000) = %10000000)
|
||||
and ((ord(Src[1]) and %11000000) = %10000000) then
|
||||
inc(Src,2);
|
||||
end
|
||||
else if ((ord(c1) and %11111000) = %11110000) then begin
|
||||
// could be 4 byte character
|
||||
if ((ord(Src[0]) and %11000000) = %10000000)
|
||||
and ((ord(Src[1]) and %11000000) = %10000000)
|
||||
and ((ord(Src[2]) and %11000000) = %10000000) then
|
||||
inc(Src,3);
|
||||
end;
|
||||
end;
|
||||
else
|
||||
inc(Src);
|
||||
c2:=Src^;
|
||||
|
||||
@ -1213,6 +1213,30 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
#192..#255:
|
||||
begin
|
||||
// read UTF8 character
|
||||
inc(p);
|
||||
if ((ord(c1) and %11100000) = %11000000) then begin
|
||||
// could be 2 byte character
|
||||
if (ord(p[0]) and %11000000) = %10000000 then
|
||||
inc(p);
|
||||
end
|
||||
else if ((ord(c1) and %11110000) = %11100000) then begin
|
||||
// could be 3 byte character
|
||||
if ((ord(p[0]) and %11000000) = %10000000)
|
||||
and ((ord(p[1]) and %11000000) = %10000000) then
|
||||
inc(p,2);
|
||||
end
|
||||
else if ((ord(c1) and %11111000) = %11110000) then begin
|
||||
// could be 4 byte character
|
||||
if ((ord(p[0]) and %11000000) = %10000000)
|
||||
and ((ord(p[1]) and %11000000) = %10000000)
|
||||
and ((ord(p[2]) and %11000000) = %10000000) then
|
||||
inc(p,3);
|
||||
end;
|
||||
CurPos.EndPos:=p-PChar(Src)+1;
|
||||
end;
|
||||
else
|
||||
inc(CurPos.EndPos);
|
||||
c2:=Src[CurPos.EndPos];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user