char字符的字符集是否保证为ASCII? [英] Is the character set of a char literal guaranteed to be ASCII?

查看:204
本文介绍了char字符的字符集是否保证为ASCII?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自讨论的讨论开始于这里,标准是否为字符指定值?所以,'0'保证是48?这是ASCII会告诉我们,但它是保证吗?如果没有,你看过'0'不是48吗?

Coming from a discussion started here, does the standard specify values for characters? So, is '0' guaranteed to be 48? That's what ASCII would tell us, but is it guaranteed? If not, have you seen any compiler where '0' isn't 48?

推荐答案

否。没有要求源或执行字符集使用具有ASCII子集的编码。我没有看到任何非ASCII实现,但我知道谁知道有人有。 (需要'0' - '9'有连续的整数值,但这是SO上其他地方的重复问题。)

No. There's no requirement for the either the source or execution character sets to use an encoding with an ASCII subset. I haven't seen any non-ASCII implementations but I know someone who knows someone who has. (It is required that '0' - '9' have contiguous integer values, but that's a duplicate question somewhere else on SO.)

用于源字符的编码set控制源代码的字节如何解释为C ++语言中使用的字符。该标准将执行字符集的成员描述为具有值。它是将这些字符映射到其对应值的编码,它确定'0'的整数值。

The encoding used for the source character set controls how the bytes of your source code are interpreted into the characters used in the C++ language. The standard describes the members of the execution character set as having values. It is the encoding that maps these characters to their corresponding values the determines the integer value of '0'.

虽然至少基本源字符集的所有成员加上一些控制字符和零值的空字符必须存在于执行字符集中(具有适当的值),但是不需要编码为ASCII或对任何特定字符子集使用ASCII值(空字符除外)。

Although at least all of the members of the basic source character set plus some control characters and a null character with value zero must be present (with appropriate values) in the execution character set, there is no requirement for the encoding to be ASCII or to use ASCII values for any particular subset of characters (other than the null character).

这篇关于char字符的字符集是否保证为ASCII?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆