Section 2.39. Expanding and Compressing Tab Characters


2.38. Encoding and Decoding Strings (uuencode/uudecode)

The uu in these names means UNIX-to-UNIX. The uuencode and uudecode utilities are a time-honored way of exchanging data in text form (similar to the way base64 is used).

str = "\007\007\002\abdce" new_string = [str].pack("u")         # '(!P<"!V)D8V4`' original   =  new_string.unpack("u") # ["\a\a\002\abdce"]


Note that an array is returned by unpack.




The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net