title: Post UTF-8 encoded data to server loses certain characters
body: <p>I am working on project which includes communication of the server (JavaEE app) and client (Android app). XML is sent as one of POST parameters of the HTTP request (named "xml"). There are also few other POST parameters which I pass to server, but in function below I removed them for simplicity. Problem that occurs is that certain letters are not properly delivered to the server - for example character <code>Ű</code> (Note that this is not German <code>Ü</code>, which is properly delivered, by the way). Code for sending is the following:</p>
  
  <pre class="lang-java prettyprint-override"><code>private String postSyncXML(String XML) {
      String url = "http://10.0.2.2:8080/DebugServlet/DebugServlet";
      HttpClient httpclient = new DefaultHttpClient();  
  
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
      nameValuePairs.add(new BasicNameValuePair("xml",XML));
  
      UrlEncodedFormEntity form;
      try {
          form = new UrlEncodedFormEntity(nameValuePairs);
                  form.setContentEncoding(HTTP.UTF_8);
          HttpPost httppost = new HttpPost(url);
  
          httppost.setEntity(form);
  
          HttpResponse response = (HttpResponse) httpclient .execute(httppost);
          HttpEntity resEntity = response.getEntity();  
          String resp = EntityUtils.toString(resEntity);
          Log.i(TAG,"postSyncXML srv response:"+resp);
          return resp;
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (ClientProtocolException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>My guess is that problem is in the BasicNameValuePair I use to set XML as one of POST parameters, and it's documentation says it uses US-ASCII character set. What is the proper way to send UTF-8 encoded POST fields?</p>