basho/erlang_protobuffs — pull request #24 by seancribbs (2012-07-11 23:07:00+00:00)
Title: Fix round-tripping problem for 'bytes' fields.

According to Google's spec([1](https://developers.google.com/protocol-buffers/docs/proto)), `bytes` fields can be arbitrary octet-sequences, whereas `string` fields must be encoded as UTF-8 or 7-bit ASCII (with top-bit of each byte 0, obviously).

It follows that in Erlang, list values assigned to `bytes` fields should be assumed to be byte-sequences and encoded using `erlang:list_to_binary/1`. This means that a list containing integers outside `0..127` will (by-design) result in a `badarg` exception.

We can still assume that lists assigned to `string` fields must be UTF-8 or ASCII, so `unicode:characters_to_binary/1` is appropriate there.

The decoding logic remains unchanged because it behaves as specified.