mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 18:13:46 +01:00
fix: recently broken unicode support in comments
This commit is contained in:
parent
a7b45ed515
commit
f8877304ee
24
hslib.pas
24
hslib.pas
@ -514,36 +514,32 @@ end; // base64decode
|
|||||||
|
|
||||||
function validUTF8(s:rawbytestring):boolean;
|
function validUTF8(s:rawbytestring):boolean;
|
||||||
var
|
var
|
||||||
i, bits, len: integer;
|
i, more, len: integer;
|
||||||
c: byte;
|
c: byte;
|
||||||
begin
|
begin
|
||||||
c:=0;
|
|
||||||
bits:=0;
|
|
||||||
len:=length(s);
|
len:=length(s);
|
||||||
i:=0;
|
i:=0;
|
||||||
while i < len do
|
while i < len do
|
||||||
begin
|
begin
|
||||||
inc(i);
|
inc(i);
|
||||||
c:=ord(s[i]);
|
c:=ord(s[i]);
|
||||||
if c < 128 then
|
if c < $80 then
|
||||||
continue;
|
continue;
|
||||||
if c >= 254 then
|
if c >= $FE then
|
||||||
exit(FALSE);
|
exit(FALSE);
|
||||||
if c >= 252 then bits:=6
|
if c >= $F0 then more:=3
|
||||||
else if c >= 248 then bits:=5
|
else if c >= $E0 then more:=2
|
||||||
else if c >= 240 then bits:=4
|
else if c >= $C0 then more:=1
|
||||||
else if c >= 224 then bits:=3
|
|
||||||
else if c >= 192 then bits:=2
|
|
||||||
else exit(FALSE);
|
else exit(FALSE);
|
||||||
if (i+bits > len) then
|
if i+more > len then
|
||||||
exit(FALSE);
|
exit(FALSE);
|
||||||
while bits > 1 do
|
while more > 0 do
|
||||||
begin
|
begin
|
||||||
inc(i);
|
inc(i);
|
||||||
c:=ord(s[i]);
|
c:=ord(s[i]);
|
||||||
if (c < 128) or (c > 191) then
|
if (c < $80) or (c > $C0) then
|
||||||
exit(FALSE);
|
exit(FALSE);
|
||||||
dec(bits);
|
dec(more);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
result:=TRUE;
|
result:=TRUE;
|
||||||
|
|||||||
@ -2062,7 +2062,8 @@ if to_ = NIL then
|
|||||||
end;
|
end;
|
||||||
l:=to_-from+1;
|
l:=to_-from+1;
|
||||||
setLength(result, l);
|
setLength(result, l);
|
||||||
if l > 0 then strLcopy(@result[1], from, l);
|
if l > 0 then
|
||||||
|
strLcopy(@result[1], from, l);
|
||||||
end; // getStr
|
end; // getStr
|
||||||
|
|
||||||
function poss(chars:TcharSet; s:string; ofs:integer=1):integer;
|
function poss(chars:TcharSet; s:string; ofs:integer=1):integer;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user