Android App that have a string papà (if I output it, i see: papà).
I send this string to a PHP script encoded as JSON and if I echo this string I read: pap�.
If I see in the database it stored as pap� (obviously).
If I write papà direclty in the database I read papà (obviously).
At this point I’m near sure that the problem is PHP, I tried with htmlentities and in the database I read papà.
I think you have all information for my problem. Any idea?
Edit to add code:
In Android I have string put in a map:
dati.put("tipo", sottoT);
after do the params for Json
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
for (Map.Entry<String, String> entry : dati.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
JSONObject json = jsonParser.makeHttpRequest(URL,
"POST", params);
I send the Json:
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
In PHP I take the data from POST:
header('Content-type=application/json; charset=utf-8');
$array = array();
foreach ($_POST as $k=>$v) {
$array[$k] = $v;
}
$v at this point is already wrong…
PHP Version 5.3.14
Just for your curiosity… i finally fix the problem. I miss to add th charset the db have to use so i put:
$conn = oci_new_connect($userDb, $pswDB, $urlDb, 'AL32UTF8');instead
$conn = oci_new_connect($userDb, $pswDB, $urlDb);So Android have:
httpPost.setEntity(new UrlEncodedFormEntity(params, "utf-8"));In Php i have:
header('Content-Type: application/json; charset=utf-8');(don’t know if this is important)This is all..ty all for help