Method: Net::BER::Extensions::String#to_ber

Defined in:
lib/adauth/net-ldap/string.rb

#to_ber(code = 0x04) ⇒ Object

Converts a string to a BER string. Universal octet-strings are tagged with 0x04, but other values are possible depending on the context, so we let the caller give us one.

User code should call either #to_ber_application_string or #to_ber_contextspecific.



18
19
20
21
# File 'lib/adauth/net-ldap/string.rb', line 18

def to_ber(code = 0x04)
  raw_string = raw_utf8_encoded
  [code].pack('C') + raw_string.length.to_ber_length_encoding + raw_string
end