Reputation: 10609
I use the following code to send data to my server:
public InputStream getStreamFromConnection(String url, List<NameValuePair> params) throws ClientProtocolException, IOException {
if(ConnectionDetector.isConnectedToInternet(this.context)) {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
return httpEntity.getContent();
} else {
return null;
}
}
When i now have a message in my params which looks like that:
The leadership earned 1000$ during the last years.
The server receives:
The leadership earned 1000
And all of the messages are cut exactly at the index of any special character. And even more. if somone writes a message with a smile like:
:)
This arrives at the server
??
How can i send the special characters and smielies to the server?
Upvotes: 0
Views: 36
Reputation: 150
It sounds like you just have to encode your URL before you execute a request with it. Try encoding your URL like this:
String encodedUrl = URLEncodedUtils.format(urlWithParameters, "utf-8");
Upvotes: 1
Reputation: 283
Do you have before your special characters this \\
?
because without it the server won't understand it.
(Sorry I couldn't leave a comment due to reputation)
Upvotes: 0