method
check_encoding

v1_9_3_125 -
Show latest stable
-
0 notes -
Class: REXML::Encoding
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
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