Delphi 2010
When reading from file using readLn procedure, by default i get unicode string converted from code page 1251 (code page of windows).
How can i change this and read from file in other code page, in 1252 or UTF16 ?
Delphi 2010
When reading from file using readLn procedure, by default i get unicode string converted from code page 1251 (code page of windows).
How can i change this and read from file in other code page, in 1252 or UTF16 ?
You can use a TStreamReader - you can specify which encoding you want to read when constructing it.
For example, TStreamReader.Create(FileName, TEncoding.UTF8);
will create a TStreamReader which can be used to read text from the file specified in FileName, using UTF-8 as the encoding.
Don't use ReadLn/WriteLn for new code. As suggested by Michael Madsen use TStreamReader in SysUtils.