method
check_encoding
check_encoding(xml)
public
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


