我正在尝试从 mydatabase中检索一些数据android app,但某些特殊字符发送不正确。数据实际上首先从我的应用程序发送,存储,然后检索。当我发送它时,数据以正确的方式注册,但在检索时似乎存在编码/解码问题。为了正确存储数据,我使用mysqli_set_charset($conn, 'utf8');了命令,因此数据Situație 4在发送时存储。发送数据的 PHP 代码:$stmt->bind_result($id, $latitudine, $longitudine, $tip_problema, $data_ora, $ora_catalogare, $validare, $grad_incredere); while($stmt->fetch()) { $locatie[] = array ( "id_alerta"=>$id, "latitudine"=>$latitudine, "longitudine"=>$longitudine, "tip_problema"=>$tip_problema, "data_ora"=>$data_ora, "ora_catalogare"=>$ora_catalogare, "stare_problema"=>$validare, "grad_incredere"=>$grad_incredere ); $response['error'] = false; $response['message'] = 'Alerte reimprospatate'; $response['locatie']= $locatie; } 我需要的信息存储在 $locatie 中,所以我可以在我的应用程序上获得 JSON 响应。输入 JSON 响应的应用代码:@Override protected void onPostExecute(String s) { super.onPostExecute(s); //hiding the progressbar after completion try { //converting response to json object JSONObject obj = new JSONObject(s); //if no error in response if (!obj.getBoolean("error")) { Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
1 回答

holdtom
TA贡献1805条经验 获得超10个赞
请尝试给 BufferedReader 编码
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
- 1 回答
- 0 关注
- 141 浏览
添加回答
举报
0/150
提交
取消