hiredis-rb
hiredis-rb copied to clipboard
Configurable encoding for Hiredis::Reader
This would bring it up to par with hiredis-py.
Shouldn't we just make sure we treat everything as binary and let the user handle encoding?
From the python version:
Unicode
hiredis.Reader
is able to decode bulk data to any encoding Python supports. To do so, specify the encoding you want to use for decoding replies when initializing it:>> reader = hiredis.Reader(encoding="utf-8") >> reader.feed("$3\r\n\xe2\x98\x83\r\n") >> reader.gets() u'☃'
When bulk data in a reply could not be properly decoded using the specified encoding, it will be returned as a plain string. When the encoding cannot be found, a
LookupError
will be raised after callinggets
for the first reply with bulk data (identical to what Python'sunicode
method would do).