Flowdock
check_encoding(str) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rexml/encoding.rb, line 57
    def check_encoding str
      # We have to recognize UTF-16, LSB UTF-16, and UTF-8
      if str[0] == 0xfe && str[1] == 0xff
        str[0,2] = ""
        return UTF_16
      elsif str[0] == 0xff && str[1] == 0xfe
        str[0,2] = ""
        return UNILE
      end
      str =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\1\s+encoding\s*=\s*(["'])(.*?)\2/um
      return $3.upcase if $3
      return UTF_8
    end
Register or log in to add new notes.