我想为一个文件格式编写语法,其内容可以包含非US-ASCII字符。由于我习惯使用ABNF,因此我尝试使用它...但是,RFC 5234和7405都不太适合那些不使用US ASCII的人。
事实上,我正在寻找一种基于字符而不是字节的ABNF版本(以及可能的一些基本规则);RFC 5234唯一关于此的说明在第2.4节中。
这并没有真正澄清问题。
是否有一个ABNF版本是基于代码点而不是字节的?
事实上,我正在寻找一种基于字符而不是字节的ABNF版本(以及可能的一些基本规则);RFC 5234唯一关于此的说明在第2.4节中。
2.4. External Encodings
External representations of terminal value characters will vary
according to constraints in the storage or transmission environment.
Hence, the same ABNF-based grammar may have multiple external
encodings, such as one for a 7-bit US-ASCII environment, another for
a binary octet environment, and still a different one when 16-bit
Unicode is used. Encoding details are beyond the scope of ABNF,
although Appendix B provides definitions for a 7-bit US-ASCII
environment as has been common to much of the Internet.
By separating external encoding from the syntax, it is intended that
alternate encoding environments can be used for the same syntax.
这并没有真正澄清问题。
是否有一个ABNF版本是基于代码点而不是字节的?
unescaped-normal-char = %x00-5B / %x7C / %x7E-D7FF / %xE000-10FFFF
。但别忘了对可怜的人类读者要友好,像这样加上注释:; 任何 Unicode 码点都可以,除了 "\","{" 和 "}"
。(还要检查排除的范围是否正确!) - Chris Morgan