Me encontré esta función
aquí, al parecer de
Peter Below
Código Delphi
[-]
procedure LoadUnicodeFile(const FileName: String; Strings: TStrings);
procedure SwapWideChars(p: PWideChar);
begin
while p^ <> #0000 do
begin
p^ := WideChar(Swap(Word(p^)));
Inc( p );
end;
end;
var
Stream: TMemoryStream;
wChar: WideChar;
pwChar: PWideChar;
begin
Stream:= TMemoryStream.Create;
try
Stream.LoadFromFile(FileName);
Stream.Seek(0, soFromEnd);
wChar := #0000;
Stream.Write(wChar, SizeOf(wChar));
pwChar := Stream.Memory;
if pwChar^ = #$FEFF then Inc(pwChar)
else if pwChar^ = #$FFFE then
begin SwapWideChars(pwChar);
Inc(pwChar);
end
else;
Strings.Text := WideChartoString(pwChar);
finally
Stream.free;
end;
end;
Su uso es muy sencillo:
Código Delphi
[-]
LoadUnicodeFile('c:\ruta\a\PLANO_WMS3.TXT', Memo1.Lines);
Ojalá te sirva.
// Saludos