gpt4 book ai didi

ascii - 大多数 ASCII 控制字符是否已过时?

转载 作者:行者123 更新时间:2023-12-04 16:03:15 28 4
gpt4 key购买 nike

\x20 下的大多数 ASCII 代码似乎完全过时了。他们今天有没有使用?它们是否可以被视为“可供抢夺”,还是最好避免它们?

我需要一个分隔符来将“行”分组在一起,为此目的选择其中一个肯定会很好。

来自 man ascii :

    Oct   Dec   Hex   Char                        
----------------------------------------------
000 0 00 NUL '\0'
001 1 01 SOH (start of heading)
002 2 02 STX (start of text)
003 3 03 ETX (end of text)
004 4 04 EOT (end of transmission)
005 5 05 ENQ (enquiry)
006 6 06 ACK (acknowledge)
007 7 07 BEL '\a' (bell)
010 8 08 BS '\b' (backspace)
011 9 09 HT '\t' (horizontal tab)
012 10 0A LF '\n' (new line)
013 11 0B VT '\v' (vertical tab)
014 12 0C FF '\f' (form feed)
015 13 0D CR '\r' (carriage ret)
016 14 0E SO (shift out)
017 15 0F SI (shift in)
020 16 10 DLE (data link escape)
021 17 11 DC1 (device control 1)
022 18 12 DC2 (device control 2)
023 19 13 DC3 (device control 3)
024 20 14 DC4 (device control 4)
025 21 15 NAK (negative ack.)
026 22 16 SYN (synchronous idle)
027 23 17 ETB (end of trans. blk)
030 24 18 CAN (cancel)
031 25 19 EM (end of medium)
032 26 1A SUB (substitute)
033 27 1B ESC (escape)
034 28 1C FS (file separator)
035 29 1D GS (group separator)
036 30 1E RS (record separator)
037 31 1F US (unit separator)
040 32 20 SPACE

最佳答案

首先是简单的部分:在大多数现代系统中没有网络传输问题。当前的协议(protocol)处理几乎所有数据——无论是 7 位 ASCII、8 位 ASCII、Unicode 字符、图像数据还是编译程序——作为二进制数据。情况并非总是如此。许多旧系统在传输控制代码和其他“不可打印”字符时存在问题,尤其是 8 位数据的问题。但幸运的是,那些日子已经过去了。一个异常(exception)情况是,如果您希望能够通过 HTML 表单复制/粘贴数据 - 为此,您希望省略所有控制代码和其他有趣的东西。

当然,您可以将格式设置为任何您喜欢的格式。但是,一些字符仍然经常使用:

000   0     00    NUL '\0' - does "nothing" but is hard for some text editors to handle
003 3 03 ETX (end of text) - Control-C - "break" in a lot of systems
007 7 07 BEL '\a' (bell) - Still makes a bell sound.
011 9 09 HT '\t' (horizontal tab) - A lot of text editors and file formats use this to set a fixed number of spaces
012 10 0A LF '\n' (new line) - like it says
015 13 0D CR '\r' (carriage ret) - used instead of, or together with \n on many systems
021 17 11 DC1 (device control 1) - Control-Q - Resume transmission - XON
023 19 13 DC3 (device control 3) - Control-S - Pause transmission - XOFF
033 27 1B ESC (escape) - Used for PCL and other printer control codes and plenty of other things

其他一切都差不多了。我会特别避免 NUL 和 XON/XOFF - 它们有时很难进入文件 - 和 BEL,因为用 BEL 输入文件可能会很吵。

如果你有一个真正的二进制格式,那么你可以做任何你想做的事情。但是,如果您想要一种大多数人可读的格式,那么限制控制代码是一个好主意。

关于ascii - 大多数 ASCII 控制字符是否已过时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49931902/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com