From cb65426b5140afcc7d051baf88caaa8528cf5c72 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 22 Aug 2006 15:25:43 +0000 Subject: * lib/rexml/source.rb (REXML::IOSource#initialize): encoding have to be set with the accessor. fixed: [ruby-list:42737] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rexml/source.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/rexml/source.rb') diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index cacab221d..c51f50481 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -135,14 +135,14 @@ module REXML # the XML spec. If there is one, we can determine the encoding from # it. str = @source.read( 2 ) - if (str[0] == 254 && str[1] == 255) || (str[0] == 255 && str[1] == 254) - @encoding = check_encoding( str ) + if /\A(?:\xfe\xff|\xff\xfe)/n =~ str + self.encoding = check_encoding( str ) @line_break = encode( '>' ) else @line_break = '>' end super str+@source.readline( @line_break ) - end + end def scan(pattern, cons=false) rv = super -- cgit