Flowdock
check_encoding(xml) 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 23
    def check_encoding(xml)
      # We have to recognize UTF-16BE, UTF-16LE, and UTF-8
      if xml[0, 2] == "\xfe\xff"
        xml[0, 2] = ""
        return 'UTF-16BE'
      elsif xml[0, 2] == "\xff\xfe"
        xml[0, 2] = ""
        return 'UTF-16LE'
      end
      xml =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\11\\s+encoding\s*=\s*(["'])(.*?)\22//
      return $3 ? $3.upcase : 'UTF-8'
    end
Register or log in to add new notes.