summaryrefslogtreecommitdiff
path: root/lib/rexml/encoding.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-22 15:25:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-22 15:25:43 +0000
commit319d2b185be7dda1fc9778da3039e12d347e5e72 (patch)
tree5969a8232a64d3e035ec7d5f7949f2bce8280cee /lib/rexml/encoding.rb
parent4da7e2b955a6f8f794c646c452e19fa46370baf3 (diff)
* lib/rexml/source.rb (REXML::IOSource#initialize): encoding have to
be set with the accessor. fixed: [ruby-list:42737] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encoding.rb')
-rw-r--r--lib/rexml/encoding.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
index 644957439e..8acc8a3698 100644
--- a/lib/rexml/encoding.rb
+++ b/lib/rexml/encoding.rb
@@ -54,8 +54,8 @@ module REXML
def check_encoding str
# We have to recognize UTF-16, LSB UTF-16, and UTF-8
- return UTF_16 if str[0] == 254 && str[1] == 255
- return UNILE if str[0] == 255 && str[1] == 254
+ return UTF_16 if /\A\xfe\xff/n =~ str
+ return UNILE if /\A\xff\xfe/n =~ str
str =~ /^\s*<?xml\s*version=(['"]).*?\2\s*encoding=(["'])(.*?)\2/um
return $1.upcase if $1
return UTF_8