mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rexml/source.rb: Move encoding detection code to base class.
* lib/rexml/encoding.rb: Remove needless encoding detection code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7ba54654a5
commit
718813ca9b
3 changed files with 61 additions and 58 deletions
|
@ -20,19 +20,6 @@ module REXML
|
|||
true
|
||||
end
|
||||
|
||||
def check_encoding(xml)
|
||||
# We have to recognize UTF-16BE, UTF-16LE, and UTF-8
|
||||
if xml[0, 2] == "\xfe\xff"
|
||||
xml[0, 2] = ""
|
||||
return 'UTF-16BE'
|
||||
elsif xml[0, 2] == "\xff\xfe"
|
||||
xml[0, 2] = ""
|
||||
return 'UTF-16LE'
|
||||
end
|
||||
xml =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\1\s+encoding\s*=\s*(["'])(.*?)\2/m
|
||||
return $3 ? $3.upcase : 'UTF-8'
|
||||
end
|
||||
|
||||
def encode(string)
|
||||
string.encode(@encoding)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue