[erlang-questions] erlang's binary representation of 7 compared to other languages

Michael Truog <>
Fri Jul 30 03:36:10 CEST 2010


I think this is just because Erlang does not recognize the "\a" encoding
and instead just recognizes "a" ("\07" seems best in this case, and is
equivalent to "\a"):
4> <<"\n">>.
<<"\n">>
5> <<"\a">>.
<<"a">>
6> <<"\07">>.
<<7>>
7>

- Michael

On 07/29/2010 06:19 PM, Woody Peterson wrote:
> 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
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>



More information about the erlang-questions mailing list