module Binascii::Uu

Public Instance Methods

a2b_uu(str) click to toggle source
# File lib/binascii/uu.rb, line 14
def a2b_uu(str)
  str.force_encoding('ASCII-8BIT')
  len = (str.getbyte(0) - 32) & 077
  str.unpack('u').first.rjust(len, "\0")
end
b2a_uu(data, backtick: false) click to toggle source
# File lib/binascii/uu.rb, line 5
def b2a_uu(data, backtick: false)
  if data.bytesize == 0
    backtick ? "`\n" : " \n"
  else
    result = [data].pack('u')
    backtick ? result : result.gsub!('`', ' ')
  end
end