You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't change the encoding of binary data to UTF-8.
It does not make sense to change the encoding of binary data, i.e., data that
already has the encoding of ASCII-8BIT or BINARY. Data stored in the jpegPhoto
attribute is an example.
irb(main):001:0> binstring = ['FFD8FFE000104A46494600'].pack('H*')
=> "\xFF\xD8\xFF\xE0\x00\x10JFIF\x00"
irb(main):002:0> binstring.encoding
=> #<Encoding:ASCII-8BIT>
irb(main):003:0> binstring.respond_to?(:encode)
=> true
irb(main):004:0> binstring.encode('UTF-8')
Encoding::UndefinedConversionError: "\xFF" from ASCII-8BIT to UTF-8
from (irb):4:in `encode'
from (irb):4
from /usr/bin/irb:12:in `<main>'
irb(main):005:0>
0 commit comments