C++ own character-encoding

2019-09-10 03:46发布

Is it possible to create an own character-encoding/ charset table and type in C++?

For example create a character-encoding with only the follow characters:

+-----------+------+
| character | code |
+-----------+------+
|     0     | 0000 |
|     1     | 0001 |
|     2     | 0010 |
|     3     | 0011 |
|     4     | 0100 |
|     5     | 0101 |
|     6     | 0110 |
|     7     | 0111 |
|     8     | 1000 |
|     9     | 1001 |
|     A     | 1010 |
|     B     | 1011 |
|     C     | 1100 |
|     D     | 1101 |
|     E     | 1110 |
|     F     | 1111 |
+-----------+------+

Like the ASCII Codes 48-57 and 65-70 but 9+1 should be A and F+1 should be 10.

1条回答
smile是对你的礼貌
2楼-- · 2019-09-10 04:14

Thanks for your help. Maybe I should rephrase the question.

Whatever, in my case the best solution was to use a bitset.

查看更多
登录 后发表回答