code_junkie

Open an ANSI file and Save a a Unicode file using Delphi

Nov 11th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var
  2. strAnsi : TGpTextFile;
  3. strUnicode: TGpTextFile;
  4. begin
  5. strAnsi := TGpTextFile.Create('c:test.udl');
  6. try
  7. strAnsi.Reset; // you can also specify non-default 8-bit codepage here
  8. strUnicode := TGpTextFile.Create('c:test-out.udl');
  9. try
  10. strUnicode.Rewrite([cfUnicode]);
  11. while not strAnsi.Eof do
  12. strUnicode.Writeln(strAnsi.Readln);
  13. finally FreeAndNil(strUnicode); end;
  14. finally FreeAndNil(strAnsi); end;
  15. end;
  16.  
  17. var
  18. sl : tStrings;
  19. Enc : tEncoding;
  20. begin
  21. sl := tStringList.Create;
  22. Enc := TUnicodeEncoding.Create;
  23. try
  24. sl.LoadFromFile(fServerDir+'configurationhdconfig4.udl');
  25. sl.SaveToFile(fServerDir+'configurationhdconfig4.udl',Enc.Unicode);
  26. finally
  27. enc.Free;
  28. sl.Free;
  29. end;
  30. end;
Add Comment
Please, Sign In to add comment