title: Broken unicode characters in PHP SoapClient
body: <p>One of our clients requires that we send some transaction information to their APIs using SOAP. One of the fields needs to be trimmed to 30 characters, so we us <code>mb_substr()</code> as follows:</p>
  
  <pre><code>$params-&gt;Request-&gt;Description = mb_substr($title, 0, 30, 'UTF-8');
  </code></pre>
  
  <p>We instantiate the <code>SoapClient</code> object as follows:</p>
  
  <pre><code>$client = new SoapClient(
                      $wsdlUri,
                      array(
                          'trace' =&gt; 1,
                          'exceptions' =&gt; true, 
                          'cache_wsdl' =&gt; WSDL_CACHE_NONE, 
                          'soap_version' =&gt; SOAP_1_2, 
                          'encoding' =&gt; 'UTF-8'
                      )
                  );
  </code></pre>
  
  <p>My understanding is that this will tell <code>SoapClient</code> that strings will be provided in UTF-8 format, and when we trim to 30 characters we are doing it to 30 UTF-8 characters, and not 30 bytes.</p>
  
  <p><code>Sound of Contact - Möbius Slip</code> is being sent as <code>Sound of Contact - MÃ¶bius Slip</code>. <code>Call of Duty®: Ghosts Gold Edition</code> is being sent as <code>Call of DutyÂ®: Ghosts Gold Edi</code>. I can see with these that we have 31 characters here, which is why the remote service is rejecting the call. If the title is less than 31 characters then it goes through fine, even when characters are mangled by the encoding.</p>
  
  <p>We know that <code>$title</code> is OK, because we send this (the whole thing) to other sources via SOAP with no problem; it is stored in the remote system and is displayed correctly. It's just this one web service that we're having a problem with. Am I doing something wrong when instantiating the <code>SoapClient</code> object? Am I using <code>mb_substr()</code> incorrectly? Is there something else that I've missed out?</p>
  
  <p>This is an example of the XML that is being generated:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://ourclient/webservices/" xmlns:ns2="http://ourclient/webservices/method/" xmlns:ns3="http://www.w3.org/2005/08/addressing"&gt;
    &lt;env:Header&gt;
      &lt;ns3:Action&gt;http://ourclient/webservices/method/action&lt;/ns3:Action&gt;
    &lt;/env:Header&gt;
    &lt;env:Body&gt;
      &lt;ns1:Method&gt;
        &lt;ns1:Request&gt;
          &lt;!-- CROPPED --&gt;
          &lt;ns1:Description&gt;Call of DutyÂ®: Ghosts Gold Edi&lt;/ns1:Description&gt;
        &lt;/ns1:Request&gt;
      &lt;/ns1:Method&gt;
    &lt;/env:Body&gt;
  &lt;/env:Envelope&gt;
  </code></pre>
  
  <p>Thanks</p>