加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

为什么回车字符不被预处理视为白色空间characetr

发布时间:2020-12-16 10:05:59 所属栏目:百科 来源:网络整理
导读:在第6.4节C标准的词汇要素中有写 … Preprocessing tokens can be separated by white space; this consists of comments (described later),or white-space characters (space,horizontal tab,new-line,vertical tab,and form-feed),or both. 如图所示,回车
在第6.4节C标准的词汇要素中有写

  1. … Preprocessing tokens can be separated by white space; this consists of
    comments (described later),or white-space characters
    (space,horizontal tab,new-line,vertical tab,and form-feed),or
    both.

如图所示,回车字符不包含在空格字符的概念中.

另一方面,在标准C函数isspace的描述中有写(7.4.1.10 isspace函数)

  1. …The standard white-space characters are the following: space (”),form feed (‘f’),new-line (‘n’),carriage return (‘r’),
    horizontal tab (‘t’),and vertical tab (‘v’). In the “C” locale,
    isspace returns true only for the standard white-space characters.

是否故意在描述预处理的部分中没有提到回车字符,如果是,那么原因是什么?

或者它只是标准的缺陷?

同样的问题对C标准有效.

解决方法

见 N1570 5.2.1第3段.

回车符是基本执行字符集的成员(并由isspace()视为空白字符),但它不是基本源字符集的一部分.

源和执行基本字符集都包括“空格字符,以及表示水平制表符,垂直制表符和换页符的控制字符”.另外,“在基本执行字符集中,应该有代表警报,退格,回车和新行的控制字符”.

在某些系统上,回车字符是行尾的指示的一部分;任何此类指示均视为单一新线.回车符不属于源文件中的行尾指示符,会导致未定义的行为.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读