-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bin 8 bit support for Ruby ASCII-8BIT data type #45
Conversation
Please note my build failed, however that is largely because the |
@iconara and @frsyuki is there any reason this isn't going to be merged in? If not, I will have to create a fork of this gem with a new namespace such as |
I'm all for it, but I'm the JRuby guy so I'll have to leave the final say to @frsyuki. If anything I would have liked to see tests for what happens when a string is not UTF-8 nor ASCII-8BIT. I might be wrong, but it looks like all non-ASCII-8BIT strings are written as raw strings, and from my understanding of the spec that is not right. Raw strings should be UTF-8, so non-UTF-8 strings need to be transcoded before they are packed. Otherwise we're back to the same problem as the old MessagePack spec: you had no idea what encoding strings were in. Here's how the JRuby implementation handles this case: https://github.com/msgpack/msgpack-ruby/blob/master/ext/java/org/msgpack/jruby/Encoder.java#L194-L196, there's also a (maybe cryptically described) test for it: https://github.com/msgpack/msgpack-ruby/blob/master/spec/jruby/msgpack_spec.rb#L131-L134 |
Thanks for the quick reply @iconara. |
@frsyuki Any feedback on this? I'm happy to use the msgpack-ably fork, but it would be nice if bin was supported in the official msgpack gem. |
@nathany I am probably going to create a MsgPackV5 fork that uses a different namespace as this fork is not ideal as the namespace would conflict if someone used both the old & forked MsgPack gems. However, if this is not a problem for you (it won't effect most people) then please do use my fork, I hope it helps. |
This Pull Request adds support for the Msgpack bin data type. If you refer to http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/, you will see that the convention for Ruby binary data is to use the
ASCII-8BIT
encoding. The Ruby MsgPack gem will now detectASCII-8BIT
when encoding and encode asbin
, and will returnASCII-8BIT
strings if the data type is bin.This PR fixes issue #44, and also resolves a few small other issues such as adding support for str 8 data type that was missing.