From: Brian Mitchell Date: 2009-08-13T07:06:49+09:00 Subject: [ruby-core:24896] Re: IDEA: Shortcut syntax for binary strings? On Wed, Aug 12, 2009 at 17:58, Gregory Brown wrote: > On Wed, Aug 12, 2009 at 4:53 PM, James Gray wrote: >> >>> bin_data = %b{71 73 70} �� # decimal values of bytes >>> bin_data.encoding �� �� �� �� # => # >> >> Interesting idea. ��I wish there was a way to keep that and Greg's simple >> ASCII usage both��� > > Hmm... yeah, I'm out of my depth here. ��But that would be nice. How about treating them like literals similar to erlang's binary syntax? bin_data = %b{ "GIF" 0xDE 0xAD 0xBE 0xEF 0b101010 } Which is like shorthand for a smart "auto-packed" array: bin_data = ["GIF", 0xDE, 0xAD, 0xBE, 0xEF, 0b101010].pack("aCCCCC") Thoughts? Brian.