實際上,我遇到了使用Rails 3.2.1在jruby-1.6.7中解析帶有REXML :: Document的XML字符串的問題。REXML :: Document.new無法使用US-ASCII編碼的XML解析
我有一個像
<?xml version="1.0" encoding="US-ASCII"?><a><b>Something</b></a>
字符串,做一個
doc = REXML::Document.new(xml_string)
截至目前,當使用JRuby的1.6.5.1工作,它失敗:
failed - can't convert NilClass into String
backtrace of deliver! org/jruby/RubyIconv.java:207:in `initialize'
org/jruby/RubyIconv.java:391:in `conv'
/opt/jruby/lib/ruby/1.8/rexml/encodings/ICONV.rb:12:in `encode'
/opt/jruby/lib/ruby/1.8/rexml/source.rb:55:in `encoding='
/opt/jruby/lib/ruby/1.8/rexml/source.rb:45:in `initialize'
/opt/jruby/lib/ruby/1.8/rexml/source.rb:11:in `create_from'
/opt/jruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:121:in `stream='
/opt/jruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:110:in `initialize'
/opt/jruby/lib/ruby/1.8/rexml/parsers/treeparser.rb:9:in `initialize'
/opt/jruby/lib/ruby/1.8/rexml/document.rb:227:in `build'
/opt/jruby/lib/ruby/1.8/rexml/document.rb:43:in `initialize'
將標題更改爲如下所示:
<?xml version="1.0" encoding="utf-8"?><a><b>Something</b></a>
一切都很好。我錯過了我的系統上的一個lib,這是一個已知的問題嗎? US-ASCII無效?