打印机开发中,对ASCII (American Standard Code for Information Interchange)的熟悉有助于相关概念的理解。同时深入理解ASCII的相关背景,也可以了解计算发展的历史。在很久以前的机械打字机时代,CR和LF分别具有不同的作用:LF会将打印纸张上移一行位置,但是保持当前打字的水平位置不变;CR则会将“Carriage”(打字机上的滚动托架)滚回到打印纸张的最左侧,但是保持当前打字的垂直位置不变,即还是在同一行。
名词解释:
CR:Carriage Return,对应ASCII中转义字符\r,表示回车;
LF:Linefeed,对应ASCII中转义字符\n,表示换行;
CRLF:Carriage Return & Linefeed,\r\n,表示回车并换行;
有兴趣的,可以看看下表的详细展示……
十进制 | 二进制 | 十六进制 | 字符/缩写 | 解释 |
0 | 0 | 0 | NUL (NULL) | 空字符 |
1 | 1 | 1 | SOH (Start Of Headling) | 标题开始 |
2 | 10 | 2 | STX (Start Of Text) | 正文开始 |
3 | 11 | 3 | ETX (End Of Text) | 正文结束 |
4 | 100 | 4 | EOT (End Of Transmission) | 传输结束 |
5 | 101 | 5 | ENQ (Enquiry) | 请求 |
6 | 110 | 6 | ACK (Acknowledge) | 回应/响应/收到通知 |
7 | 111 | 7 | BEL (Bell) | 响铃 |
8 | 1000 | 8 | BS (Backspace) | 退格 |
9 | 1001 | 9 | HT (Horizontal Tab) | 水平制表符 |
10 | 1010 | 0A | LF/NL(Line Feed/New Line) | 换行键 |
11 | 1011 | 0B | VT (Vertical Tab) | 垂直制表符 |
12 | 1100 | 0C | FF/NP (Form Feed/New Page) | 换页键 |
13 | 1101 | 0D | CR (Carriage Return) | 回车键 |
14 | 1110 | 0E | SO (Shift Out) | 不用切换 |
15 | 1111 | 0F | SI (Shift In) | 启用切换 |
16 | 10000 | 10 | DLE (Data Link Escape) | 数据链路转义 |
17 | 10001 | 11 | DC1/XON (Device Control 1/Transmission On) | 设备控制1/传输开始 |
18 | 10010 | 12 | DC2 (Device Control 2) | 设备控制2 |
19 | 10011 | 13 | DC3/XOFF(Device Control 3/Transmission Off) | 设备控制3/传输中断 |
20 | 10100 | 14 | DC4 (Device Control 4) | 设备控制4 |
21 | 10101 | 15 | NAK (Negative Acknowledge) | 无响应/非正常响应/拒绝接收 |
22 | 10110 | 16 | SYN (Synchronous Idle) | 同步空闲 |
23 | 10111 | 17 | ETB (End of Transmission Block) | 传输块结束/块传输终止 |
24 | 11000 | 18 | CAN (Cancel) | 取消 |
25 | 11001 | 19 | EM (End of Medium) | 已到介质末端/介质存储已满/介质中断 |
26 | 11010 | 1A | SUB (Substitute) | 替补/替换 |
27 | 11011 | 1B | ESC (Escape) | 逃离/取消 |
28 | 11100 | 1C | FS (File Separator) | 文件分割符 |
29 | 11101 | 1D | GS (Group Separator) | 组分隔符/分组符 |
30 | 11110 | 1E | RS (Record Separator) | 记录分离符 |
31 | 11111 | 1F | US (Unit Separator) | 单元分隔符 |
32 | 100000 | 20 | (Space) | 空格 |
33 | 100001 | 21 | ! | exclamation mark |
34 | 100010 | 22 | “ | double quote |
35 | 100011 | 23 | # | number sign |
36 | 100100 | 24 | $ | dollar sign |
37 | 100101 | 25 | % | percent |
38 | 100110 | 26 | & | ampersand |
39 | 100111 | 27 | ‘ | single quote |
40 | 101000 | 28 | ( | left/opening parenthsis |
41 | 101001 | 29 | ) | right/opening parenthsis |
42 | 101010 | 2A | * | asterisk |
43 | 101011 | 2B | + | plus |
44 | 101100 | 2C | , | comma |
45 | 101101 | 2D | – | minus or dash |
46 | 101110 | 2E | . | dot |
47 | 101111 | 2F | / | forward slash |
48 | 110000 | 30 | 0 | |
49 | 110001 | 31 | 1 | |
50 | 110010 | 32 | 2 | |
51 | 110011 | 33 | 3 | |
52 | 110100 | 34 | 4 | |
53 | 110101 | 35 | 5 | |
54 | 110110 | 36 | 6 | |
55 | 110111 | 37 | 7 | |
56 | 111000 | 38 | 8 | |
57 | 111001 | 39 | 9 | |
58 | 111010 | 3A | : | |
59 | 111011 | 3B | ; | |
60 | 111100 | 3C | < | |
61 | 111101 | 3D | = | |
62 | 111110 | 3E | > | |
63 | 111111 | 3F | ? | |
64 | 1000000 | 40 | @ | |
65 | 1000001 | 41 | A | |
66 | 1000010 | 42 | B | |
67 | 1000011 | 43 | C | |
68 | 1000100 | 44 | D | |
69 | 1000101 | 45 | E | |
70 | 1000110 | 46 | F | |
71 | 1000111 | 47 | G | |
72 | 1001000 | 48 | H | |
73 | 1001001 | 49 | I | |
74 | 1001010 | 4A | J | |
75 | 1001011 | 4B | K | |
76 | 1001100 | 4C | L | |
77 | 1001101 | 4D | M | |
78 | 1001110 | 4E | N | |
79 | 1001111 | 4F | O | |
80 | 1010000 | 50 | P | |
81 | 1010001 | 51 | Q | |
82 | 1010010 | 52 | R | |
83 | 1010011 | 53 | S | |
84 | 1010100 | 54 | T | |
85 | 1010101 | 55 | U | |
86 | 1010110 | 56 | V | |
87 | 1010111 | 57 | W | |
88 | 1011000 | 58 | X | |
89 | 1011001 | 59 | Y | |
90 | 1011010 | 5A | Z | |
91 | 1011011 | 5B | [ | left/opening bracket |
92 | 1011100 | 5C | \ | back slash |
93 | 1011101 | 5D | ] | right/closing bracket |
94 | 1011110 | 5E | ^ | caret/circumflex |
95 | 1011111 | 5F | _ | underscore |
96 | 1100000 | 60 | ` | |
97 | 1100001 | 61 | a | |
98 | 1100010 | 62 | b | |
99 | 1100011 | 63 | c | |
100 | 1100100 | 64 | d | |
101 | 1100101 | 65 | e | |
102 | 1100110 | 66 | f | |
103 | 1100111 | 67 | g | |
104 | 1101000 | 68 | h | |
105 | 1101001 | 69 | i | |
106 | 1101010 | 6A | j | |
107 | 1101011 | 6B | k | |
108 | 1101100 | 6C | l | |
109 | 1101101 | 6D | m | |
110 | 1101110 | 6E | n | |
111 | 1101111 | 6F | o | |
112 | 1110000 | 70 | p | |
113 | 1110001 | 71 | q | |
114 | 1110010 | 72 | r | |
115 | 1110011 | 73 | s | |
116 | 1110100 | 74 | t | |
117 | 1110101 | 75 | u | |
118 | 1110110 | 76 | v | |
119 | 1110111 | 77 | w | |
120 | 1111000 | 78 | x | |
121 | 1111001 | 79 | y | |
122 | 1111010 | 7A | z | |
123 | 1111011 | 7B | { | left/opening brace |
124 | 1111100 | 7C | | | vertical bar |
125 | 1111101 | 7D | } | right/closing brace |
126 | 1111110 | 7E | ~ | tilde |
127 | 1111111 | 7F | DEL (Delete) | 删除 |