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