gpt4 book ai didi

C18 标准中的矛盾(关于字符集)?

转载 作者:行者123 更新时间:2023-12-03 20:49:37 25 4
gpt4 key购买 nike

我们在 C18 标准中读到:

5.1.1.2 Translation phases

The precedence among the syntax rules of translation is specified by the following phases.

  1. Physical source file multibyte characters are mapped, in an implementation-defined manner, to the source character set (introducing new-line characters for end-of-line indicators) if necessary.

意思是源文件字符集 被解码并映射到 源字符集。
但是你可以阅读:

5.2.1 Character sets

Two sets of characters and their associated collating sequences shall be defined: the set in which source files are written (the source character set), and the set interpreted in the execution environment (the execution character set).


意思是源文件字符集 源字符集。
所以问题是:我理解的是哪个错误,或者哪个实际上是错误的?
编辑:实际上 我错了 .看我下面的回答。

最佳答案

Meaning that the source file character set is decoded and mapped to the source character set.


不,不是那个意思。我的看法是,已经假定源代码是用源字符集编写的——“将源字符集映射到源字符集”究竟有什么意义?他们要么是该系列的一部分,要么不是。如果您为源代码选择了错误的编码,它甚至会在预处理开始之前就被拒绝。
翻译阶段 1 做了两件与此完全无关的事情:
  • 解析三合字母,这是标准化的多字节序列。
  • 将多字节字符映射到源字符集(在 5.2.1 中定义)。
    源字符集由基本字符集(本质上是拉丁字母表加上各种常用符号 (5.2.1/3))和扩展字符集(特定于区域设置和实现)组成。
    多字节字符的定义见 5.2.1.2:

    The source character set may contain multibyte characters, used to represent members ofthe extended character set. The execution character set may also contain multibytecharacters, which need not have the same encoding as for the source character set.


    意味着各种特定于语言环境的奇怪的特殊情况,例如特定于语言环境的三合字母。

  • 所有这些多字节的疯狂都可以追溯到 1990 年的第一次标准化——根据该委员会成员的轶事,这是因为来自不同欧洲国家的成员无法在他们的国家键盘上使用各种符号。
    (我不确定当时此类键盘上的 AltGr 键有多普遍。无论如何,在非英语键盘上写 C 时,它仍然是一个受到严重按钮混搭的键,以访问 {}[] 符号等.)

    关于C18 标准中的矛盾(关于字符集)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63548478/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com