1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/branches/ruby_1_8@10779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2006-08-25 13:32:39 +00:00
parent eb8ed37c16
commit ad4cffb204
3 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,8 @@
Fri Aug 25 22:32:04 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]
Fri Aug 25 17:15:17 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* stable version 1.8.5 released.

View file

@ -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

View file

@ -135,8 +135,8 @@ 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 = '>'