逐行读取流
Delphi中有没有办法逐行读取流?
有没有办法设置流的编码?
我知道
TEncoding.getEncodingPage(1250);
如何从流中获取它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找
TStreamReader
。您在构造函数中设置编码,然后调用ReadLine
< /a>.就如何从流中获取编码而言,这很大程度上取决于流中的内容,不是吗?
I think you're looking for
TStreamReader
. You set the encoding in the constructor and then callReadLine
.In terms of how to get the encoding from the stream, that depends very much on what is in the stream, doesn't it?
缺少
TStreamReader
的 Delphi 版本可以使用 Peter下面的StreamIO单元,它为您提供AssignStream
。它的工作方式与AssignFile
类似,但针对的是流而不是文件名。使用该函数将流与TextFile
变量关联后,您可以像调用任何其他文件一样调用ReadLn
以及其他 I/O 函数。Delphi versions that lack
TStreamReader
can use Peter Below's StreamIO unit, which gives youAssignStream
. It works just likeAssignFile
, but for streams instead of file names. Once you've used that function to associate a stream with aTextFile
variable, you can callReadLn
and the other I/O functions on it just like any other file.