使用二进制数据测试文件中的EOF [英] Testing for EOF in file with binary data
问题描述
问候!
我正在开发一个需要读取包含HP LaserJet PCL代码的lp
生成的打印文件的C应用程序。如果PCL包含二进制数据到
定义要在页面上打印的位图,无论是图标还是软字体
下载,EOF测试都会提前结束,而不是阅读整个
文件。如何绕过EOF测试而不检测文件中的EOF值
?我错过了什么吗?
更多数据:
如果打印文件只包含文本数据或没有位图
值,打印文件正确读取。
建议?
提前致谢!
David Warner
-
comp.lang.c.moderated - 审核地址: cl ** @ plethora.net - 您必须
在您的标题中有适当的新闻组行,以便查看您的邮件,
或主题行中方括号中的新闻组名称。对不起。
Greetings!
I am working on a C app that needs to read print files generated by lp
that contain HP LaserJet PCL codes. If the PCL contains binary data to
define a bit map to be printed on the page, either icon or soft-font
download, the EOF test ends prematurely and does not read the entire
file. How do I get around testing for EOF and not detect the EOF value
within the file? Am I missing something?
More Data:
If the print file just contains text data or does not have a bit map
value, the print file is read correctly.
Suggestions?
Thanks in advance!
David Warner
--
comp.lang.c.moderated - moderation address: cl**@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
推荐答案
[交叉发布删除]
David Warner写道:
[cross-posting deleted]
David Warner wrote:
我正在开发一个需要读取包含HP LaserJet PCL代码的lp
生成的打印文件的C应用程序。如果PCL包含二进制数据以定义要在页面上打印的位图,无论是图标还是软字体下载,EOF测试都会提前结束并且不会读取整个
文件。如何绕过EOF测试而不检测文件中的EOF值?我错过了什么吗?
I am working on a C app that needs to read print files generated by lp
that contain HP LaserJet PCL codes. If the PCL contains binary data to
define a bit map to be printed on the page, either icon or soft-font
download, the EOF test ends prematurely and does not read the entire
file. How do I get around testing for EOF and not detect the EOF value
within the file? Am I missing something?
我们更喜欢这个组中的std :: fstreams,但是相同的解决方案可以用C或C ++风格工作
文件流:使用文件大小而不是EOF
字符来确定您读取的数据量。您可以在C ++中使用
fstream :: seekg()和fstream :: tellg(),或者使用等价物来获取该信息。
>
干杯! --M
We prefer std::fstreams in this group, but the same solution can work
with C or C++ style file streams: use the file size rather than the EOF
character to determine how much data you read. You can use
fstream::seekg() and fstream::tellg() in C++ or the C equivalents to
get that info.
Cheers! --M
" mlimber" <毫升***** @ gmail.com>在留言中写道
news:11 ********************** @ g10g2000cwb.googlegr oups.com ......
"mlimber" <ml*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
[交叉发布删除]
David Warner写道:
[cross-posting deleted]
David Warner wrote:
我正在开发一个需要读取lp生成的打印文件的C app
包含HP LaserJet PCL代码。如果PCL包含二进制数据以定义要在页面上打印的位图,无论是图标还是软字体下载,EOF测试都会提前结束并且不会读取整个
文件。如何绕过EOF测试而不检测文件中的EOF值?我错过了什么?
I am working on a C app that needs to read print files generated by lp
that contain HP LaserJet PCL codes. If the PCL contains binary data to
define a bit map to be printed on the page, either icon or soft-font
download, the EOF test ends prematurely and does not read the entire
file. How do I get around testing for EOF and not detect the EOF value
within the file? Am I missing something?
我们更喜欢这个组中的std :: fstreams,但是相同的解决方案可以用C或C ++样式的文件流工作:使用文件大小而不是比EOF
字符确定你读取了多少数据。您可以在C ++中使用
fstream :: seekg()和fstream :: tellg(),或者使用C等价物来获取该信息。
We prefer std::fstreams in this group, but the same solution can work
with C or C++ style file streams: use the file size rather than the EOF
character to determine how much data you read. You can use
fstream::seekg() and fstream::tellg() in C++ or the C equivalents to
get that info.
真正的答案是fgetc和朋友在int中的回报,
不是char。 EOF的值可以与您从二进制流中读取的任何char值区分开来。
PJ Plauger
Dinkumware,Ltd 。
http://www.dinkumware.com
在消息< Io ******************** @ giganews.com> ;,, PJ Plauger
< pj*@dinkumware.com>写道
In message <Io********************@giganews.com>, P.J. Plauger
<pj*@dinkumware.com> writes
" mlimber" <毫升***** @ gmail.com>在消息中写道
新闻:11 ********************** @ g10g2000cwb.googleg roups.com ...
"mlimber" <ml*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googleg roups.com...
[交叉发布已删除]
David Warner写道:
[cross-posting deleted]
David Warner wrote:
我正在开发一个需要读取lp生成的打印文件的C应用程序
包含HP LaserJet PCL代码。如果PCL包含二进制数据以定义要在页面上打印的位图,无论是图标还是软字体下载,EOF测试都会提前结束并且不会读取整个
文件。如何绕过EOF测试而不检测文件中的EOF值?我错过了什么?
I am working on a C app that needs to read print files generated by lp
that contain HP LaserJet PCL codes. If the PCL contains binary data to
define a bit map to be printed on the page, either icon or soft-font
download, the EOF test ends prematurely and does not read the entire
file. How do I get around testing for EOF and not detect the EOF value
within the file? Am I missing something?
我们更喜欢这个组中的std :: fstreams,但是相同的解决方案可以用C或C ++样式的文件流工作:使用文件大小而不是比EOF
字符确定你读取了多少数据。你可以在C ++或C等价物中使用
fstream :: seekg()和fstream :: tellg()来获取那些信息。
We prefer std::fstreams in this group, but the same solution can work
with C or C++ style file streams: use the file size rather than the EOF
character to determine how much data you read. You can use
fstream::seekg() and fstream::tellg() in C++ or the C equivalents to
get that info.
真正的答案是fgetc和朋友在int中的回报,
不是char。 EOF的值可以与您从二进制流中读取的任何char值区分开来。
The real answer is that the return from fgetc and friends in an int,
not a char. The value of EOF is distinguishable from any char value
you read from a binary stream.
OP实际上并未明确表示他是否 ; EOF"意味着宏
或者只是文件结束条件的缩写,他实际上是比较一个字符与宏EOF的比较,或者他是否正在调用feof()
函数?
在后一种情况下,第一个问题是:他实际打开了
文件吗?在二进制模式?在文本模式下,至少有一个操作系统
将控制-Z解释为文件结束并产生一个不成熟的
终止。 />
-
Richard Herring
The OP hasn''t actually made it clear whether his "EOF" means the macro
or is just an abbreviation for "end-of-file condition", Is he actually
comparing a char against the macro EOF, or is he calling the feof()
function?
In the latter case, the first question is: has he actually opened the
file in binary mode? In text mode, there''s at least one OS out there
that will interpret control-Z as end-of-file and produce a premature
termination.
--
Richard Herring
这篇关于使用二进制数据测试文件中的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!