Home > Articles > Programming > Ruby

📄 Contents

  • Print
  • + Share This
This chapter is from the book

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.

  • + Share This
  • 🔖 Save To Your Account