module HexaPDF::DictionaryFields::StringConverter

def self.additional_types

:nodoc:
def self.additional_types
end

def self.convert(str, _type, document)

converted). Otherwise returns +nil+.
Converts the string into UTF-8 encoding, assuming it is a binary string (i.e. one not yet
def self.convert(str, _type, document)
  return unless str.kind_of?(String) && str.encoding == Encoding::BINARY
  if str.getbyte(0) == 254 && str.getbyte(1) == 255
    str = str[2..-1].force_encoding(Encoding::UTF_16BE)
    if str.valid_encoding?
      str.encode!(Encoding::UTF_8)
    else
      document.config['document.on_invalid_string'].call(str)
    end
  else
    Utils::PDFDocEncoding.convert_to_utf8(str)
  end
end

def self.usable_for?(type)

This converter is usable if the +type+ is the String class.
def self.usable_for?(type)
  type == String
end