mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 03:39:17 +02:00
LazUtils: In UCS2BEToUTF8 and UCS2LEToUTF8 skip little/big endian BOM. Merge request !88 by Zaher Dirkey.
This commit is contained in:
parent
88b3151b38
commit
76f7524436
@ -505,8 +505,13 @@ begin
|
||||
len:=length(s) div 2;
|
||||
if len=0 then
|
||||
exit('');
|
||||
SetLength(Result,len*3);// UTF-8 is at most 3/2 times the size
|
||||
Src:=PWord(Pointer(s));
|
||||
if (Src^=$FEFF) then // Skip BOM
|
||||
begin
|
||||
inc(Src);
|
||||
dec(len);
|
||||
end;
|
||||
SetLength(Result,len*3);// UTF-8 is at most 3/2 times the size
|
||||
Dest:=PChar(Result);
|
||||
for i:=1 to len do begin
|
||||
c:=LEtoN(Src^);
|
||||
@ -536,8 +541,13 @@ begin
|
||||
len:=length(s) div 2;
|
||||
if len=0 then
|
||||
exit('');
|
||||
SetLength(Result,len*3);// UTF-8 is at most three times the size
|
||||
Src:=PWord(Pointer(s));
|
||||
if (Src^=$FFFE) then // Skip BOM
|
||||
begin
|
||||
inc(Src);
|
||||
dec(len);
|
||||
end;
|
||||
SetLength(Result,len*3);// UTF-8 is at most three times the size
|
||||
Dest:=PChar(Result);
|
||||
for i:=1 to len do begin
|
||||
c:=BEtoN(Src^);
|
||||
|
Loading…
Reference in New Issue
Block a user