Einzelnen Beitrag anzeigen

Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.580 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: $0 in stream and loading as text

  Alt 25. Aug 2014, 14:45
If you dont want to save your data, then you can load the file into a TMemoryStream (or a string) and replace the #0 with another character.
This is only unicode text, so the problem is not to replace those bytes, but to read the file with correct encoding.
If one did it this way and there is only one real unicode character inside, one would get really strange results...

Even if there is no byte order mark this code works perfectly for me:
Delphi-Quellcode:
var
  test: TStringStream;
begin
  test := TStringStream.Create('', TEncoding.Unicode);
  try
    test.LoadFromFile('c:\temp\a.txt');
    ShowMessage(test.DataString);
  finally
    test.Free;
  end;
end;
So it would be better, if you would attach a working sample code with an example file...
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat