问题:
在Android向Python实现的Wsgi接口发送json格式的http请求是,server不能正确解析,入库的中文字段为一串问号???????,在server端反复解码无效,查找资料,是在Android发送json时没有指定utf8,指定后,一切OK。
即在发送的时候用utf-8编码,接收的时候用utf-8解码即可! HttpPost httpPost = new HttpPost(url); StringEntity se = new StringEntity(jsonObject.toString(), “UTF-8″); httpPost.setEntity(se); se.setContentType(“application/json”); HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost); String retSrc = EntityUtils.toString(httpResponse.getEntity(), “UTF-8″); JSONObject result = new JSONObject( retSrc);