What is the default encoding for C strings?

后端 未结 5 865
后悔当初
后悔当初 2020-12-01 11:34

I know that C strings are char[] with a \'\\0\' in the last element. But how are the chars encoded?

Update: I found this cool link which talks about many other prog

5条回答
  •  独厮守ぢ
    2020-12-01 11:42

    All the standard says on the matter is that you get at least the 52 upper- and lower-case latin alphabet characters, the digits 0 to 9, the symbols ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~, and the space character, and control characters representing horizontal tab, vertical tab, and form feed.

    The only thing it says about numeric encoding is that all of the above fits in one byte, and that the value of each digit after zero is one greater that the value of the previous one.

    The actual encoding is probably inherited from your locale settings. Probably something ASCII-compatible.

提交回复
热议问题