开发者

Delphi Standard Input Output Code page

开发者 https://www.devze.com 2022-12-27 23:51 出处:网络
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).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消