diff --git a/lib/net/ber/core_ext/string.rb b/lib/net/ber/core_ext/string.rb index d52d787..8c7a345 100644 --- a/lib/net/ber/core_ext/string.rb +++ b/lib/net/ber/core_ext/string.rb @@ -20,7 +20,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 - self.encode('UTF-8').force_encoding('ASCII-8BIT') + begin + self.encode('UTF-8').force_encoding('ASCII-8BIT') + rescue Encoding::UndefinedConversionError + self + end else self end