Hi,
I’m running ruby 1.9.2-p0 on Centos 5.5 x86_64 along with rails 2.3.8.
I have XMLRPC server on another windows machine (rails 1.9.1) and XMLRPC
client on the Centos machine. I need to return UTF-8 encoded data from
server to client and this is where I’m stuck.
The Server seems to be sending correct UTF-8 encoded data, bud client is
unable to parse the XML. If the XML contains ASCII only strings,
everything’s OK, but once there is any multi-byte UTF-8 character, ruby
bails out and outputs this:
REXML::ParseException (#<Encoding::CompatibilityError: incompatible
encoding regexp match (UTF-8 regexp with ASCII-8BIT string)>
/usr/local/lib/ruby/1.9.1/rexml/source.rb:212:in match' /usr/local/lib/ruby/1.9.1/rexml/source.rb:212:in
match’
/usr/local/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:425:in pull' /usr/local/lib/ruby/1.9.1/rexml/parsers/streamparser.rb:16:in
parse’
/usr/local/lib/ruby/1.9.1/rexml/document.rb:204:in parse_stream' /usr/local/lib/ruby/1.9.1/xmlrpc/parser.rb:717:in
parse’
/usr/local/lib/ruby/1.9.1/xmlrpc/parser.rb:460:in parseMethodResponse' /usr/local/lib/ruby/1.9.1/xmlrpc/client.rb:421:in
call2’
/usr/local/lib/ruby/1.9.1/xmlrpc/client.rb:410:in `call’
…
There seems to be something wrong with REXML non-ASCII data parsing or
maybe encoding detection. I’ve tracked it down to the “match” method in
IOSource wrapper class in rexml/source.rb file. The problem seems to be
that the @buffer which the method matches against contains ASCII-8bit
string sometimes. Strangely, it happens only when it contains some
non-ASCII data. If there are only ASCII characters in @buffer, it
happily proceeds as UTF-8.
BTW, my client script looks like this:
module SubmitFilesHelper
@rpc_server_url=‘http://172.16.1.2:3000’
def self.sendToServer(filename,language)
require ‘xmlrpc/client’
server = XMLRPC::Client.new2(@rpc_server_url)
result = server.call(‘check’, filename,language)
end
end
Centos has locale set to en_us.UTF-8
Is there anything I’m doing wrong, or is it ruby bug?
Thanks,
Petr