为什么 C99 对通用字符名称有如此奇怪的限制?

2024-02-07

6.4.3 通用角色名称 http://c0x.coding-guidelines.com/6.4.3.html

通用字符名称不得指定除 0024 ($)、0040 (@) 或 0060 (`) 之外的短标识符小于 00A0 的字符,也不得指定 D800 到 DFFF(含)范围内的字符。

除了这样的限制不再“通用”之外,我想不出这种限制的充分理由。有人知道背景故事吗?


D800通过DFFF包含在内的不是有效的代码点;它们是高代理和低代理,只能在 UTF-16 编码中成对找到,以表示基本平面之外的代码点。

The other restriction avoids having a universal character name collide with a character which could be represented in the C character set, for the benefit of compilers which don't bother resolving universal character names into their unicode equivalents. So the compiler is under no obligation to recognize a + written as \u002B or to know that a and \u0061 represent the same name. ($, @ and ` are not valid in a C program outside of comments and character strings, so they do not require any special attention from the lexer.)

码位范围小于A0还包括控制字符和空格。 (C 不考虑\u00A0成为空白。)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 C99 对通用字符名称有如此奇怪的限制? 的相关文章

随机推荐