Merge pull request #41 from justcfx2u/master
Fall back if string cannot be encoded
This commit is contained in:
commit
ccd7b6da5b
1 changed files with 5 additions and 1 deletions
|
@ -28,7 +28,11 @@ module Net::BER::Extensions::String
|
|||
if self.respond_to?(:encode)
|
||||
# Strings should be UTF-8 encoded according to LDAP.
|
||||
# However, the BER code is not necessarily valid UTF-8
|
||||
begin
|
||||
self.encode('UTF-8').force_encoding('ASCII-8BIT')
|
||||
rescue Encoding::UndefinedConversionError
|
||||
self
|
||||
end
|
||||
else
|
||||
self
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue