mirror of
https://github.com/rejetto/hfs2.git
synced 2025-12-19 10:03:56 +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;
|
||||
var
|
||||
i, bits, len: integer;
|
||||
i, more, len: integer;
|
||||
c: byte;
|
||||
begin
|
||||
c:=0;
|
||||
bits:=0;
|
||||
len:=length(s);
|
||||
i:=0;
|
||||
while i < len do
|
||||
begin
|
||||
inc(i);
|
||||
c:=ord(s[i]);
|
||||
if c < 128 then
|
||||
if c < $80 then
|
||||
continue;
|
||||
if c >= 254 then
|
||||
if c >= $FE then
|
||||
exit(FALSE);
|
||||
if c >= 252 then bits:=6
|
||||
else if c >= 248 then bits:=5
|
||||
else if c >= 240 then bits:=4
|
||||
else if c >= 224 then bits:=3
|
||||
else if c >= 192 then bits:=2
|
||||
if c >= $F0 then more:=3
|
||||
else if c >= $E0 then more:=2
|
||||
else if c >= $C0 then more:=1
|
||||
else exit(FALSE);
|
||||
if (i+bits > len) then
|
||||
if i+more > len then
|
||||
exit(FALSE);
|
||||
while bits > 1 do
|
||||
while more > 0 do
|
||||
begin
|
||||
inc(i);
|
||||
c:=ord(s[i]);
|
||||
if (c < 128) or (c > 191) then
|
||||
if (c < $80) or (c > $C0) then
|
||||
exit(FALSE);
|
||||
dec(bits);
|
||||
dec(more);
|
||||
end;
|
||||
end;
|
||||
result:=TRUE;
|
||||
|
||||
@ -2062,7 +2062,8 @@ if to_ = NIL then
|
||||
end;
|
||||
l:=to_-from+1;
|
||||
setLength(result, l);
|
||||
if l > 0 then strLcopy(@result[1], from, l);
|
||||
if l > 0 then
|
||||
strLcopy(@result[1], from, l);
|
||||
end; // getStr
|
||||
|
||||
function poss(chars:TcharSet; s:string; ofs:integer=1):integer;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user