Converting Between ASCII and EBCDIC

 

ddThe first time I was handed an EBCDIC tape, I discovered the wonders of the standard UNIX utility dd. It is great for reading tapes generated on non-UNIX systems. (The GNU version of dd is on the CD-ROM.)

You do need to understand a bit about the blocking factors on the foreign tape , (20.6) but once you've got that down, you can handle just about anything.

For example, to read an EBCDIC tape on tape device /dev/rmt0 and convert it to ASCII, putting the output in file was_ibm:

% dd if=/dev/rmt0 of=was_ibm ibs=800 cbs=80 conv=ascii

dd reads standard input and writes to standard output, but if you want to specify file or device names, you can use the fairly non-standard if= and of= options to specify the input file and output file, respectively.

If you wanted to convert the other way, you could use this command:

% dd if=was_unix of=/dev/rmt0 obs=800 cbs=80 conv=ebcdic

There's also a conv=ibm option, which uses a different ASCII to EBCDIC conversion table. According to the dd manual page, "The ASCII/EBCDIC conversion tables are taken from the 256 character standard in the CACM Nov, 1968. The ibm conversion, while less blessed as a standard, corresponds better to certain IBM print train conventions. There is no universal solution."

Some gotchas:

  • You need to be able to read the raw device (20.3) to do the conversion, since the tape probably doesn't use standard UNIX tape block sizes.

  • You need to know the blocking factor of the foreign tape, so you can tell dd about it.

  • If the foreign tape has multiple files on it, you'll have to use the tape device name that allows "no rewind on close" (20.3) to read past the first file.

One last thing to mention about dd: all options that refer to sizes expect counts in bytes, unless otherwise mentioned. However, you can use keyletters to indicate various types of multiplication: k means to multiply by 1024; b to multiply by 512 (a block); and w to multiply by 4 (word). You can also show an arbitrary multiplication by separating two numbers with an x.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值