的std :: IOS ::二进制? [英] std::ios::binary?

查看:89
本文介绍了的std :: IOS ::二进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

§27.4.2.1.4输入ios_base :: openmode

说明std :: ios :: binary openmode标志:

* binary *:执行输入以二进制模式输出(与文本模式相反)


这基本上是_all_它说的。二元

标志意味着什么呢?

-

如果我们的假设是关于任何事情而不是关于某一个或多个/>
特别的东西,然后我们的推论构成数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell

解决方案

* Steven T. Hatton:

§27.4.2.1.4类型ios_base :: openmode
说到这个std :: ios :: binary openmode标志:
* binary *:以二进制模式执行输入和输出(与文本模式相反)

这基本上是_all_它说的关于它。二进制
标志意味着什么?




基本上它意味着i / o函数不应该进行任何翻译

来自/来自数据的外部表示:它们应该表现为它们实际应该在默认情况下表现出来,但遗憾的是没有。


例如,一个Windows文本文件的每一行都通过回车终止

+ linefeed,而不是Unix中的换行符,而在文本模式中''\ n''是

相应地翻译输出,并且这些序列在输入时被转换为

''\ n'' - 在实践中''\ r''是回车符和''\ n''另外,例如,在Windows文本文件中,Ctrl Z表示文件结尾。

这对包含

a二进制文件开头的简短描述性文本片段,但我怀疑它原本是对

Uni的误解x shell命令立即发送当前行(对于空的

模式下,Ctrl Z可能会在输入时被转换为文件结尾。


有趣的是C ++ iostream实用程序是如此极其设计糟糕

你不能在系统上只使用标准C ++库制作一个简单的复制 - 标准 - 输入 - 标准 - 输出 - 完全

程序这是有意义的,但文本翻译是在文本模式下进行的。


当然,宗教C ++的人认为不应该这样做

无论如何都是因为你不能在手机上做到这一点,其中C ++可能用于某些东西,但是他们忘记了i / o是有一个原因。

-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和电子邮件中最烦人的是什么?


Steven T. Hatton写道:§27.4.2.1.4类型ios_base :: openmode
关于std :: ios :: binary openmode标志的说法:
* binary *:以二进制执行输入和输出模式(与文本模式相反)

这基本上是_all_它说的。二进制
标志意味着什么?




在某些平台上\ n转换为\\\\ n当写入(并且

反向读取时)写入文件而其他文件没有写入文件时。二元模式

将不会进行此类翻译。


Gianni Mariani写道:

Steven T. Hatton写道:

§27.4.2.1.4类型ios_base :: openmode
说这是关于std :: ios :: binary openmode标志:
* binary *:执行输入并以二进制模式输出(而不是文本模式)

这基本上是_all_它说的。
二进制标志意味着什么?



在某些平台上\ n转换为\\\\ n当写入(和读取时反转)到文件时,它不会。二元模式
将不会进行这样的翻译。




是按照标准,还是强制实施?我知道,当我想到二进制I / O时,你通常会想到的是你所描述的内容。对于

的例子,在古代我们曾经明确告诉ftp使用

二进制模式转移。


-

如果我们的假设是关于任何事情而不是关于某一个或多个特定事物,那么我们的推论就构成了数学。因此,数学可能被定义为我们永远不知道我们所讨论的是什么,以及我们所说的是否属实的主题.- Bertrand Russell


§27.4.2.1.4 Type ios_base::openmode
Says this about the std::ios::binary openmode flag:
*binary*: perform input and output in binary mode (as opposed to text mode)

And that is basically _all_ it says about it. What the heck does the binary
flag mean?
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

解决方案

* Steven T. Hatton:

§27.4.2.1.4 Type ios_base::openmode
Says this about the std::ios::binary openmode flag:
*binary*: perform input and output in binary mode (as opposed to text mode)

And that is basically _all_ it says about it. What the heck does the binary
flag mean?



Basically it means that the i/o functions should not do any translation
to/from external representation of the data: they should behave as they
really should have behaved by default, but unfortunately do not.

For example, a Windows text file has each line terminated by carriage return
+ linefeed, as opposed to just linefeed in Unix, and in text mode ''\n'' is
translated accordingly for output, and these sequences are translated to
''\n'' on input -- in practice ''\r'' is carriage return and ''\n'' is linefeed.

Also, for example, in a Windows text file Ctrl Z denotes end-of-file.
That''s useful for including a short descriptive text snippet at the start of
a binary file, but I suspect it was originally a misunderstanding of the
Unix shell command to send the current line immediately (which for an empty
line means zero bytes, which in Unix indicates end-of-file). So in text
mode in Windows, a Ctrl Z might be translated to end-of-file on input.

Interestingly the C++ iostream utilities are so extremely badly designed
that you can''t make a simple copy-standard-input-to-standard-output-exactly
program using only the standard C++ library, on systems where this is
meaningful but text translation occurs in text mode.

Of course, the religious C++''ers maintain that that shouldn''t be possible
anyway because you can''t do it on, say, a mobile phone, where C++ could be
used for something, but then they forget that i/o is there for a reason.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Steven T. Hatton wrote:

§27.4.2.1.4 Type ios_base::openmode
Says this about the std::ios::binary openmode flag:
*binary*: perform input and output in binary mode (as opposed to text mode)

And that is basically _all_ it says about it. What the heck does the binary
flag mean?



On some platforms "\n" translates to "\r\n" when written (and the
reverse when read) to a file while on others it does not. binary mode
will make no such translation.


Gianni Mariani wrote:

Steven T. Hatton wrote:

§27.4.2.1.4 Type ios_base::openmode
Says this about the std::ios::binary openmode flag:
*binary*: perform input and output in binary mode (as opposed to text
mode)

And that is basically _all_ it says about it. What the heck does the
binary flag mean?



On some platforms "\n" translates to "\r\n" when written (and the
reverse when read) to a file while on others it does not. binary mode
will make no such translation.



Is that per the Standard, or "implementation imposed"? I know that what you
describe is what I typically think of when I think of binary I/O. For
example, in ancient times we used to have to explicitly tell ftp to use
binary mode transfer.

--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell


这篇关于的std :: IOS ::二进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆