diff options
author | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-04 04:52:08 +0000 |
---|---|---|
committer | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-04 04:52:08 +0000 |
commit | 06f2b5b1d890253cdc4de78a326369a10d22595b (patch) | |
tree | d72a3afeb172bb2c4318c3b6d9e499b5a3e5e7ce /lib/rexml/source.rb | |
parent | b3ab1dbf34f9ab5b69462c1b7aa8575c27cf8f65 (diff) | |
download | ruby-06f2b5b1d890253cdc4de78a326369a10d22595b.tar.gz |
Fixes ticket:110 (more UTF-16 problems)
Missing include for UndefinedNamespaceException was causing errors in some
cases.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/source.rb')
-rw-r--r-- | lib/rexml/source.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index 659bcdc195..e05460fea1 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -135,6 +135,7 @@ module REXML def initialize(arg, block_size=500, encoding=nil) @er_source = @source = arg @to_utf = false + # Determining the encoding is a deceptively difficult issue to resolve. # First, we check the first two bytes for UTF-16. Then we # assume that the encoding is at least ASCII enough for the '>', and @@ -146,13 +147,16 @@ module REXML str = @source.read( 2 ) if encoding self.encoding = encoding - elsif /\A(?:\xfe\xff|\xff\xfe)/n =~ str - self.encoding = check_encoding( str ) - elsif (0xef == str[0] && 0xbb == str[1]) + elsif 0xfe == str[0] && 0xff == str[1] + @line_break = "\000>" + elsif 0xff == str[0] && 0xfe == str[1] + @line_break = ">\000" + elsif 0xef == str[0] && 0xbb == str[1] str += @source.read(1) str = '' if (0xbf == str[2]) + @line_break = ">" else - @line_break = '>' + @line_break = ">" end super str+@source.readline( @line_break ) end |