Skip to content

Instantly share code, notes, and snippets.

@makaroni4
Created April 4, 2012 20:33
Show Gist options
  • Save makaroni4/2305376 to your computer and use it in GitHub Desktop.
Save makaroni4/2305376 to your computer and use it in GitHub Desktop.
How to find out pack argument
# assert_equal "あいうえお".unpack('__'), [12354, 12356, 12358, 12360, 12362]
['S', 'L', 'Q', 'c', 's', 'l', 'q', 'S_', 'S!', 'I', 'I_', 'I', 'L_', 'L!', 's_', 's!', 'i', 'i_', 'i', 'l_', 'l!', 'S>', 'L>', 'Q>', 's>', 'l>', 'q>', 'S!>', 'I!>', 'L!>', 's!>', 'i!>', 'l!>', 'S<', 'L<', 'Q<', 's<', 'l<', 'q<', 'S!<', 'I!<', 'L!<', 's!<', 'i!<', 'l!<', 'n', 'N', 'v', 'V', 'U', 'w', 'a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm', 'P', 'p', '@', 'x', 'X', 'D', 'd', 'F', 'f', 'E', 'e', 'G', 'g'].each do |a|
begin
p "あいうえお".unpack("#{a}*")
rescue
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment