summaryrefslogtreecommitdiff
path: root/lib/rexml/encoding.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-04 04:52:08 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-04 04:52:08 +0000
commit06f2b5b1d890253cdc4de78a326369a10d22595b (patch)
treed72a3afeb172bb2c4318c3b6d9e499b5a3e5e7ce /lib/rexml/encoding.rb
parentb3ab1dbf34f9ab5b69462c1b7aa8575c27cf8f65 (diff)
Fixes ticket:110 (more UTF-16 problems)
Missing include for UndefinedNamespaceException was causing errors in some cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encoding.rb')
-rw-r--r--lib/rexml/encoding.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
index 6cae6b644d..a01763be99 100644
--- a/lib/rexml/encoding.rb
+++ b/lib/rexml/encoding.rb
@@ -56,8 +56,13 @@ module REXML
def check_encoding str
# We have to recognize UTF-16, LSB UTF-16, and UTF-8
- return UTF_16 if /\A\xfe\xff/n =~ str
- return UNILE if /\A\xff\xfe/n =~ str
+ 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