Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • pack

    Posted on June 25th, 2009 RubyLove No comments

    The pack function packs the given arguments into a binary string according to format provided as a parameter.

    PHP

    $binary_string = pack("nvc*", 0x1234, 0x5678, 65, 66);

    Ruby

    a = [0x1234, 0x5678, 65, 66];
     
    binary_string = a.pack("nvc*");

    Leave a reply