Question mark (Chinese) displayed when java posts data to phppost. php post. chinese. php post. chinese. java
I verified several statuses.
Echo "Hello"; // Hello
Echo json_encode ("Hello") // u4f60/u597d I don't care
Echo $ _ POST ['key'] //?
In fact, I am working on android. the connection package is under org. apache. http.
How to post Chinese to php
Reply to discussion (solution)
Encoding problems
Echo base64_encode ($ _ POST ['key']);
Post result
Encoding problem, the received post value needs to be transcoded, iconv
Echo base64_encode ($ _ POST ['key']);
Post result
Send 'you' to show Pw =
Echo base64_decode ('pw = '); // output?
That is to say, when sending, 'you' has changed '? '
Echo base64_decode ('pw = '); // output?
That is to say, when sending, 'you' has changed '? '
The decode output is indeed '? '
I think it should be about java and php encoding.
Because if I use php to store Chinese characters in the variables, it is okay to query mysql.
Do you know how to change the encoding in php. ini?
Echo base64_decode ('pw = '); // output?
That is to say, when sending, 'you' has changed '? '
It seems that it may be wrong when sending the message. no matter what the Chinese word is, Pw = if both words are, Pz8 =
The request is obtained in this way.
The addHeader in is meaningless.
List
listParams = new ArrayList
();if (params != null){for (String name : params.keySet()){listParams.add(new BasicNameValuePair(name, params.get(name)));}}try{UrlEncodedFormEntity entity = new UrlEncodedFormEntity(listParams);HttpPost request = new HttpPost(url);request.addHeader("charset", HTTP.UTF_8);request.setEntity(entity);return request;
This? That? You may have encountered encoding conversion problems, mark
Okay, thank you.
UrlEncodedFormEntity entity = new UrlEncodedFormEntity (listParams); // change UrlEncodedFormEntity entity = new UrlEncodedFormEntity (listParams, HTTP.UTF-8 );
If possible, comment it out.