mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rexml: 1.9 patch from Sam Ruby mentioned in his blog:
<http://intertwingly.net/blog/2007/12/31/Porting-REXML-to-Ruby-1-9> [ruby-core:14639] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
96e7713754
commit
1448668244
16 changed files with 91 additions and 67 deletions
|
@ -59,6 +59,9 @@ module REXML
|
|||
@to_utf = true
|
||||
else
|
||||
@to_utf = false
|
||||
if @buffer.respond_to? :force_encoding
|
||||
@buffer.force_encoding Encoding::UTF_8
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -147,13 +150,13 @@ module REXML
|
|||
str = @source.read( 2 )
|
||||
if encoding
|
||||
self.encoding = encoding
|
||||
elsif 0xfe == str[0] && 0xff == str[1]
|
||||
elsif str[0,2] == "\xfe\xff"
|
||||
@line_break = "\000>"
|
||||
elsif 0xff == str[0] && 0xfe == str[1]
|
||||
elsif str[0,2] == "\xff\xfe"
|
||||
@line_break = ">\000"
|
||||
elsif 0xef == str[0] && 0xbb == str[1]
|
||||
elsif str[0,2] == "\xef\xbb"
|
||||
str += @source.read(1)
|
||||
str = '' if (0xbf == str[2])
|
||||
str = '' if (str[2,1] == "\xBF")
|
||||
@line_break = ">"
|
||||
else
|
||||
@line_break = ">"
|
||||
|
@ -193,6 +196,9 @@ module REXML
|
|||
str = @source.readline(@line_break)
|
||||
str = decode(str) if @to_utf and str
|
||||
@buffer << str
|
||||
if not @to_utf and @buffer.respond_to? :force_encoding
|
||||
@buffer.force_encoding Encoding::UTF_8
|
||||
end
|
||||
rescue Exception, NameError
|
||||
@source = nil
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue