Ver Mensaje Individual
  #7  
Antiguo 16-08-2012
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
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 // normal byte order mark
      Inc(pwChar)
    else if pwChar^ = #$FFFE then
    begin // byte order is big-endian
      SwapWideChars(pwChar);
      Inc(pwChar);
    end
    else; // no byte order mark

    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
Responder Con Cita