Mega Code Archive

 
Categories / Ruby / Array
 

Binary conversion with pack See also String unpack

[1,2,3,4].pack("CCCC")    # => "\001\002\003\004" [1,2].pack('s2')          # => "\001\000\002\000" [1234].pack("i")          # => "\322\004\000\000"