erlang's binary representation of 7 compared to other languages

Woody Peterson woody.peterson@REDACTED
Fri Jul 30 03:19:04 CEST 2010


I have a problem that's on the borders of ruby and erlang, and I  
figured the erlang list would generally be more familiar with binary  
issues. And forgive me for my haziness with the terminology here...

The basic problem is that ruby encodes the integer 7 as "\a", while  
erlang only decodes it as "\007". Ruby *will* decode both "\007" and  
"\a" into 7, which makes me think there's more than one opinion about  
how it should be encoded.

The bigger problem is I'm trying to send data from ruby to erlang via  
BERT, and turns out it can't handle data (broadly defined) of length 7.

Here's some code examples:

ruby:

     [7].pack("C") # => "\a"
     "\a".unpack("C") # => 7
     "\007".unpack("C") # => 7

erlang:

     <<"\a">>. % => <<a>>
     <<"\007">>. % => <<7>>

That's all I've got. Not sure exactly what to google here, "erlang OR  
ruby binary 007" doesn't really get me anywhere (suprise!), plus I'm  
not sure what exactly this encoding/decoding specification is called.

Any help is appreciated, even google terms :p

-Woody


More information about the erlang-questions mailing list