title: Delphi XE3 - datasnap REST server UTF8 output
body: <p>I am implementing the REST service in Delphi XE3. Actually accessing:</p>
  
  <pre><code>var metaData: TDSInvocationMetadata;
  metaData.ResponseContent:= output;
  </code></pre>
  
  <p>to generate the XML output. Unfotunatelly after hours of testing various UTF8 to Unicode conversion methods I am still not able to get correct UTF8 output. Here is my example:</p>
  
  <pre><code>function TServerMethods1.UTF8TEST(Value: string): string;
   var metaData: TDSInvocationMetadata;
       output: String;
  begin
    metaData:= GetInvocationMetadata;
    output:= '&lt;element&gt;&lt;inside name="skúška" /&gt;&lt;/element&gt;';
    metaData.ResponseCode:= 200;
    metaData.ResponseContentType:= 'text/xml; charset=utf-8';
    metaData.ResponseContent:= utf8encode(output);
  end;
  </code></pre>
  
  <p>After calling from the internet browser: <a href="http://localhost:8080/datasnap/rest/TServerMethods1/UTF8TEST" rel="nofollow">http://localhost:8080/datasnap/rest/TServerMethods1/UTF8TEST</a> I got ENCODING ERROR report. After removing the special characters 'úš' and set the name to 'skuska' only, evrythink seem to be fine.</p>
  
  <p>Anyone could help how to get correctly UTF8 encoded output ???</p>