Delphi Standard Input Output Code page
Delphi 2010
When reading from file using rea开发者_运维技巧dLn 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 ?
Don't use ReadLn/WriteLn for new code. As suggested by Michael Madsen use TStreamReader in SysUtils.
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.
精彩评论