2015-03-07, 17:34
Hi,
I am accessing the api via an self-written Android client. When I try to play a file by directly launching it via open, I have the problem that I can not play titles containing special characters (like umlaut 'ü').
Example:
{"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"smb://NAS/Videos/Filme/Misc/Das fünfte Element.ts"}},"id":1}"
However when I use SoapUI to do the same thing everything works like a charm.
I assume I have to set a character encoding, but I have not idea what exactly I have to to.
Currently I use the following code:
protected String doInBackground(String... urls)
{
String response = "";
{
DefaultHttpClient client = new DefaultHttpClient();
String url = urls[0];
String jsonString = urls[1];
HttpPost httpPost = new HttpPost(url);
StringEntity se = null;
try
{
se = new StringEntity(jsonString);
se.setContentType("application/json;charset=UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
httpPost.setEntity(se);
try
{
HttpResponse httpResponse = client.execute(httpPost);
response = EntityUtils.toString(httpResponse.getEntity());
}
catch (Exception e)
{
e.printStackTrace();
}
}
return response;
}
}
As you can see, I am using UTF-8, but I have already tried without setting UTF-8 but to no avail...
Any ideas would be very welcome.
Thanx,
Rudi
I am accessing the api via an self-written Android client. When I try to play a file by directly launching it via open, I have the problem that I can not play titles containing special characters (like umlaut 'ü').
Example:
{"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"smb://NAS/Videos/Filme/Misc/Das fünfte Element.ts"}},"id":1}"
However when I use SoapUI to do the same thing everything works like a charm.
I assume I have to set a character encoding, but I have not idea what exactly I have to to.
Currently I use the following code:
protected String doInBackground(String... urls)
{
String response = "";
{
DefaultHttpClient client = new DefaultHttpClient();
String url = urls[0];
String jsonString = urls[1];
HttpPost httpPost = new HttpPost(url);
StringEntity se = null;
try
{
se = new StringEntity(jsonString);
se.setContentType("application/json;charset=UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
httpPost.setEntity(se);
try
{
HttpResponse httpResponse = client.execute(httpPost);
response = EntityUtils.toString(httpResponse.getEntity());
}
catch (Exception e)
{
e.printStackTrace();
}
}
return response;
}
}
As you can see, I am using UTF-8, but I have already tried without setting UTF-8 but to no avail...
Any ideas would be very welcome.
Thanx,
Rudi