Implementation of UrlEncode and Rawurlencode in PHP in Java

Source: Internet
Author: User
Tags urlencode

This is explained in the PHP manual for UrlEncode.

in Java Urlencoder made such comments.

in other words, the asterisk "*" is not encoded in Java. after Urlencoder or "*", PHP UrlEncode is returned%2A

Java and PHP to the space are processed into "+"

To achieve consistency between Java and PHP UrlEncode, you can do this in Java:

Java:output "+%2A"

System.out.println(Urlencoder.encode ("*", "UTF-8"). Replace ("*", "%2a"));

Php:output "+%2A"

Echo UrlEncode ("+*");

The Rawurlencode in PHP is treated as a%20 asterisk ' * ' and processed into%2A

PHP Output%20%2A

echo Rawurlencode ("*");

This is what you need to do in Java to implement Rawurlencode in PHP.

Java output%20%2a

System.out.println (Urlencoder.encode ("*", "UTF-8"). Replace ("*", "%2a"). Replace ("+", "%20"))

Implementation of UrlEncode and Rawurlencode in PHP in Java

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.