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

Cha*_*hap 8 ascii control-characters delimiter

\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                       
Run Code Online (Sandbox Code Playgroud)

man*_*ica 4

首先是简单的部分:大多数现代系统中不存在网络传输问题。当前协议将几乎所有数据(无论是 7 位 ASCII、8 位 ASCII、Unicode 字符、图像数据还是编译程序)作为二进制数据处理。但情况并非总是如此。许多旧系统在传输控制代码和其他“不可打印”字符时存在问题,尤其是 8 位数据的问题。但幸运的是,那些日子已经过去了。一个很大的例外是,如果您希望能够通过 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 
Run Code Online (Sandbox Code Playgroud)

其他一切都可以争夺。我会特别避免 NUL 和 XON/XOFF(它们有时很难输入到文件中)和 BEL,因为使用 BEL 键入文件可能会很吵。

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

  • 为了具体回答这个问题,换页将文件划分为逻辑块是很常见的。 (2认同)