Question mark is displayed in Chinese when the java Post data to PHP

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.