When Java posts data to PHP, Chinese displays question mark question

Source: Internet
Author: User
PHP post Chinese php post Chinese Java

I've verified a couple of states.
echo "Hello"; How are you doing
echo json_encode ("Hello")///u4f60/u597d I don't care
echo $_post[' key '//??

Actually I'm doing Android, the connection is org.apache.http under the

Solving how to post to PHP Chinese


Reply to discussion (solution)

It's a coding problem.

echo base64_encode ($_post[' key ');
Post the results

Encoding problem, received post value requires transcoding, Iconv

echo base64_encode ($_post[' key ');
Post the results

Send ' you ' to show pw==

echo base64_decode (' pw== '); Output?
That means ' you ' have become '? ' at the time of sending. The

echo base64_decode (' pw== '); Output?
That means ' you ' have become '? ' at the time of sending. The


The decode output is really '? '

I think it's a Java and PHP coding problem.
Because I PHP if the variable in Chinese, go to MySQL to do the query is no problem

Do you know how to change the code in php.ini?

echo base64_decode (' pw== '); Output?
That means ' you ' have become '? ' at the time of sending. The

It seems that it is possible to send the wrong time, no matter what the Chinese word is pw== if it is two words are pz8=

That's how you get the request.
The AddHeader don't know if there's any point.

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 one? That one? You seem to have a code conversion problem, mark.

All right, thank you, I've already solved this.

urlencodedformentity entity = new Urlencodedformentity (                        listparams);//change to urlencodedformentity entity = new Urlencodedformentity (                        listparams,http. UTF-8);

If possible, just 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.