Robert Speicher
Robert Speicher

Reputation: 15562

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>

Upvotes: 0

Views: 1514

Answers (2)

mu is too short
mu is too short

Reputation: 434685

"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?

Upvotes: 2

Robert Speicher
Robert Speicher

Reputation: 15562

I believe I figured out the problem, thanks to mu's comment on my original post.

IP.Board's XMLRPC server was receiving the UTF-8 data correctly, but it wasn't displaying it correctly on the front end. The problem lied with a IP.Board configuration setting, "Character Encoding" in "Server Environment" that, for some reason, was set to ISO-8859-1 instead of UTF-8. Changing the value to UTF-8 fixed the display issue.

Upvotes: 2

Related Questions