* 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
This commit is contained in:
nobu 2006-08-22 15:25:43 +00:00
Родитель 4da7e2b955
Коммит 319d2b185b
3 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Wed Aug 23 00:25:14 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rexml/source.rb (REXML::IOSource#initialize): encoding have to
be set with the accessor. fixed: [ruby-list:42737]
Tue Aug 22 19:21:00 2006 Minero Aoki <aamine@loveruby.net> Tue Aug 22 19:21:00 2006 Minero Aoki <aamine@loveruby.net>
* lib/net/smtp.rb: parameter `to_addrs' might be an Array, * lib/net/smtp.rb: parameter `to_addrs' might be an Array,

Просмотреть файл

@ -54,8 +54,8 @@ module REXML
def check_encoding str def check_encoding str
# We have to recognize UTF-16, LSB UTF-16, and UTF-8 # We have to recognize UTF-16, LSB UTF-16, and UTF-8
return UTF_16 if str[0] == 254 && str[1] == 255 return UTF_16 if /\A\xfe\xff/n =~ str
return UNILE if str[0] == 255 && str[1] == 254 return UNILE if /\A\xff\xfe/n =~ str
str =~ /^\s*<?xml\s*version=(['"]).*?\2\s*encoding=(["'])(.*?)\2/um str =~ /^\s*<?xml\s*version=(['"]).*?\2\s*encoding=(["'])(.*?)\2/um
return $1.upcase if $1 return $1.upcase if $1
return UTF_8 return UTF_8

Просмотреть файл

@ -135,14 +135,14 @@ module REXML
# the XML spec. If there is one, we can determine the encoding from # the XML spec. If there is one, we can determine the encoding from
# it. # it.
str = @source.read( 2 ) str = @source.read( 2 )
if (str[0] == 254 && str[1] == 255) || (str[0] == 255 && str[1] == 254) if /\A(?:\xfe\xff|\xff\xfe)/n =~ str
@encoding = check_encoding( str ) self.encoding = check_encoding( str )
@line_break = encode( '>' ) @line_break = encode( '>' )
else else
@line_break = '>' @line_break = '>'
end end
super str+@source.readline( @line_break ) super str+@source.readline( @line_break )
end end
def scan(pattern, cons=false) def scan(pattern, cons=false)
rv = super rv = super