PHPbase64_encode encrypts the Chinese string and uses java to decode part of the Garbled text.

Source: Internet
Author: User
Example: The word "yungojunhua. Phpurlencode is used at the beginning, and then javaurldecode, the word "quit" is called zookeeper. Use PHPbase64_encode, and then use javadecode (org. apache. commons. codec. binary. base64 package), & quot; success & quot; word OK, but "... example: The word "yungojunhua.

Php urlencode is used at the beginning, and then the java urldecode, "encoding" is used.

Use PHP base64_encode, and then use java decode (org. apache. commons. codec. binary. base64 package), the word "Jun" is OK, but the word "Jun Hua" is wrongly formed.

Search is a non-standard base64 decoding algorithm used by java, so.

Reply content:

Example: The word "yungojunhua.

Php urlencode is used at the beginning, and then the java urldecode, "encoding" is used.

Use PHP base64_encode, and then use java decode (org. apache. commons. codec. binary. base64 package), the word "Jun" is OK, but the word "Jun Hua" is wrongly formed.

Search is a non-standard base64 decoding algorithm used by java, so.

The garbled characters are caused by inconsistent codes.
The urlencode encoding in php is consistent with the system encoding (for example, windows Default gb2312 and ubuntu default UTF-8)
Therefore, you must first determine your system encoding, and then pass in the encoding when calling the java decode method based on the obtained system encoding (considering that your example contains traditional Chinese characters, we recommend that you use UTF-8 encoding. The following is an example of using UTF-8 encoding (in the php environment, ubuntun)


  

Output: % E8 % 98% 8B % E6 % 9E % 9C % E5 % 90% 9B % E5 % 8D % 8E

        String ret = java.net.URLDecoder.decode("%E8%98%8B%E6%9E%9C%E5%90%9B%E5%8D%8E", "utf-8");        System.out.println(ret);

Output: yunguo Junhua

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.