本文介绍了价值ASCII名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让ASCII值的名称。

Is there a way to get the name of the value of ascii.

例如:

0x08的或仅仅8退格键

0x08 or just 8 is the backspace

我可以用C或C获取名称退格++?

can I get the name "Backspace" in c or c++?

推荐答案

在短,没有。轻松工作围绕,虽然。

In short, no. Easily worked around, though.

如果您的ASCII code为< 32,下面是标准的ASCII控制字符缩写表你可以使用:

If your ASCII code is < 32, here's table of standard ASCII control character abbreviations you can use:

char *ascii_cc[] = {
  "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", 
  "BS",  "HT",  "LF",  "VT",  "FF",  "CR",  "SO",  "SI",
  "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
  "CAN", "EM",  "SUB", "ESC", "FS",  "GS",  "RS",  "US" };

然后,只需指数成的值字符串数组的字符你感兴趣。例如。

char c = 8; /* backspace */
printf("ASCII control code = %s\n", ascii_cc[c]);

这篇关于价值ASCII名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 09:36