Closed jwarchol closed 8 years ago
Yeah, that's not expected (I'm a bit surprised by it tbqh). It should be encoded = actual_string.dup.force_encoding 'binary'
.
Since I'm not paid to work on this library anymore, I might have time to work on tests and a fix for that tomorrow. If you want it sooner, I'd love to help you contribute a fix :)
I had an issue recently where ActiveRecord queries started falling over with
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
errors after an attribute was added to a beefcake call. I tracked it back to beefcakeforce_encoding
the strings we passed in to binary, rather than making binary encoded copies of them. Is this as expected?https://github.com/protobuf-ruby/beefcake/blob/31985ead1a327fe554da6c153bba0003b9d53dae/lib/beefcake/buffer/encode.rb#L109
This line reads like it doesn't expect
force_encoding
to modify the string in place, which is what the method does.