in Android Code Tips, Java

UTF-8 encoding at post values with HttpClient

It took me a while to find out how, so I believe it will be useful for you too.

HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("name1", "utfvalue1"));
nameValuePairs.add(new BasicNameValuePair("name2", "utfvalue2"));
UrlEncodedFormEntity formEntity = null;
try {
	formEntity = new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
} catch (UnsupportedEncodingException e2) {
if (formEntity != null)