method

check_encoding

v1_9_2_180 - Show latest stable - Class: REXML::Encoding
check_encoding(str)
public

No documentation available.

# 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,2] == "\xfe\xff"
        str[0,2] = ""
        return UTF_16
      elsif str[0,2] == "\xff\xfe"
        str[0,2] = ""
        return UNILE
      end
      str =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\11\\s+encoding\s*=\s*(["'])(.*?)\22//
      return $3.upcase if $3
      return UTF_8
    end