Without BOM the File was read as ANSI. Change the following and you can read this case correctly...
Code: Select all
procedure TUnicodeStrings.LoadFromStream(Stream: TStream);
:
// default case (Ansi)
if not Loaded then
begin
FSaveFormat := sfAnsi;
SetLength(SA, Size div SizeOf(AnsiChar));
if BytesRead > 0 then
begin
System.Move(ByteOrderMask[0], SA[1], BytesRead); // max 6 bytes = 6 chars
if Size > BytesRead then
Stream.Read(SA[7], Size - BytesRead); // first 6 chars were copied by System.Move
SW := UTF8Decode(SA);
if SW <> '' then begin
FSaveFormat := sfUTF8;
SetTextStr(SW);
Loaded := True;
end;
end;
if not Loaded then
SetTextStr(SA);
end;