summaryrefslogtreecommitdiffstats
path: root/lib/rexml/encodings
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-11 02:48:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-11 02:48:17 +0000
commit8dc5f69e139af81001f6f2201951fd47a01daebf (patch)
treef89148671efd94b1acfbbd299ceae518a5137ec7 /lib/rexml/encodings
parent083d6a34ce0c49bc59d8e7158bab0c149d0678ac (diff)
downloadruby-8dc5f69e139af81001f6f2201951fd47a01daebf.tar.gz
ruby-8dc5f69e139af81001f6f2201951fd47a01daebf.tar.xz
ruby-8dc5f69e139af81001f6f2201951fd47a01daebf.zip
* lib/rexml/source.rb (REXML::Source::encoding): should not
convert the body twice. [ruby-core:08828] * lib/rexml/encoding.rb (REXML::Encoding::encoding): Encoding#encoding= to return boolean value to tell if the body is really converted or not. * lib/rexml/encoding.rb (REXML::Encoding::encoding): Specific conversion library (e.g. rexml/encodings/UTF-16.rb) to have higher preceding. * lib/rexml/encodings/UTF-16.rb (REXML::Encoding::decode_utf16): UTF-16#decode_utf16 should work strings without BOM. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encodings')
-rw-r--r--lib/rexml/encodings/UTF-16.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rexml/encodings/UTF-16.rb b/lib/rexml/encodings/UTF-16.rb
index 972169755..792adfd44 100644
--- a/lib/rexml/encodings/UTF-16.rb
+++ b/lib/rexml/encodings/UTF-16.rb
@@ -16,9 +16,10 @@ module REXML
end
def decode_utf16(str)
+ str = str[2..-1] if /^\376\377/ =~ str
array_enc=str.unpack('C*')
array_utf8 = []
- 2.step(array_enc.size-1, 2){|i|
+ 0.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
}
array_utf8.pack('U*')