as/400如何识别文件的编码?cat正确地打印了两个不同的编码



在QSHELL中,我用不同的编码对具有相同文本的两个文件进行cat,并且两者都打印相同的内容,看(hell.txt是EBCDIC,hellascii.txt是ASCII(:

cat hellascii.txt
hello@@@@@

cat hell.txt
hello@@@@@

od-x hell.txt
0000000 4040 4040 8885 9393 9640 7c7c 7c 7c7c
0000020 7c25
0000022

od-x hellascii.txt
0000000 2020 6865 6c6c6c 6f20 4040 4040
0000020 4000
00000 21

在我的laptob中,在linux或mac中,EBCDIC编码显示其他看起来混乱的字符。as400中的unix如何正确打印两者?我没有看到任何指示编码的文件头。例如,0x40在ascii中是@,在EBCDIC中是空格,但cat在hell.txt中正确地将0x40打印为空格,在hellascii.txt中正确打印为@。

在IBMi上,系统跟踪分配给每个IFS文件的CCSID。您可以使用od的-C选项来查看CCSID。下面是一个例子。

$ od -tx -C helloascii.txt
helloascii.txt CCSID = 819
0000000  68692074 68657265 0a000000
0000011
$ od -tx -C helloebcdic.txt
helloebcdic.txt CCSID = 256
0000000  888940a3 88859985 25000000
0000011

您可以使用触摸的-C选项来分配新文件的CCSID。以下是我如何创建上面使用的文件。

$ touch -C 819 helloascii.txt
$ echo 'hi there' >> helloascii.txt
$ touch -C 256 helloebcdic.txt
$ echo 'hi there' >> helloebcdic.txt

最新更新