在C / C ++中编写非打印字符的行为是什么? [英] What is the behavior of writing a non-printing character in C/C++?
问题描述
如果通过 printf
/ fprintf $写入字符,则写入非打印字符的行为是未定义的还是实现定义的C $ C>?我很困惑,因为C标准N1570 / 5.2.2中的单词只讨论打印字符和字母转义序列的显示语义。
Is the behavior of writing a non-printing character undefined or implementation-defined, if the character is written via printf
/fprintf
? I am confused because the words in the C standard N1570/5.2.2 only talks about the display semantics for printing characters and alphabetic escape sequences.
此外,如果字符是通过 std :: ostream
(仅限C ++)写的?
In addition, what if the character is written via std::ostream
(C++ only)?
推荐答案
ASCII不可打印(控制)字符的输出是实现定义的。
The output of ASCII non-printable (control) characters is implementation defined.
具体来说,解释是输出设备的责任。
Specifically, interpretation is the responsibility of the output device.
编辑1:
输出设备作为文件打开时,可以打开二进制
。当以二进制
打开时,输出不会被翻译(例如行结尾)。
Edit 1:
When the output device is opened as a file, it can be opened as binary
. When opened as binary
the output is not translated (e.g. line endings).
这篇关于在C / C ++中编写非打印字符的行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!