Search code examples
rubyutf-8character-encodingxml-rpcinvision-power-board

XML-RPC call is munging special characters


For reasons beyond my control, I'm having to utilize an XML-RPC interface. My client is Ruby, the server is PHP. My problem is that any "special" characters in the message get altered along the way.

For example, here's a call I might make in Ruby:

server   = XMLRPC::Client.new2('http://mysite.com/path/to/server/')
response = server.call('postTopic', {
  :topic_title  => "Tsígö"
})

Note the two special characters in the :topic_title param.

When it reaches the server, this is what that log shows:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>postTopic</methodName>
   <params>
      <param>
         <value>
            <struct>
               <member>
                  <name>topic_title</name>
                  <value>
                     <string>Tsígö</string>
                  </value>
               </member>
            </struct>
         </value>
      </param>
   </params>
</methodCall>

Solution

  • "Tsà gö" is "Tsígö" interpreted as an ISO-8859-1 (AKA Latin-1) encoded string. So, is the server actually UTF-8 aware or is it blindly treating everything as Latin-1 despite the specified encoding?