Skip to content

Conversation

@wandns
Copy link

@wandns wandns commented Jul 30, 2013

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

'
irb(main):005:0>

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>
@jch
Copy link
Member

jch commented Oct 7, 2014

@wandns sorry for the slow response, but we're rebooting development efforts with https://groups.google.com/d/msg/ruby-ldap/3y6g1Oqgvd0/vy5DaAcwF_cJ. Can you rebase your changes off the latest master, and add some tests?

@jch jch closed this Oct 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants