read streams line by line

假装没事ソ 提交于 2019-12-19 09:09:19

问题


Is there a way in Delphi to read streams ,line by line?

Is there a way to set the encoding of the stream?

I know of

TEncoding.getEncodingPage(1250); 

How to get it from stream?


回答1:


I think you're looking for TStreamReader. You set the encoding in the constructor and then call ReadLine.

In terms of how to get the encoding from the stream, that depends very much on what is in the stream, doesn't it?




回答2:


Delphi versions that lack TStreamReader can use Peter Below's StreamIO unit, which gives you AssignStream. It works just like AssignFile, but for streams instead of file names. Once you've used that function to associate a stream with a TextFile variable, you can call ReadLn and the other I/O functions on it just like any other file.



来源:https://stackoverflow.com/questions/6942704/read-streams-line-by-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!