UrlEncode ()

Source: Internet
Author: User
Tags urlencode alphanumeric characters

UrlEncodeThe urlencode function URL encodes the passed-in string parameter. Its returned string in addition to the "ˉ-.” , all non-alphanumeric characters are replaced with a percent sign (%) followed by a two-digit hexadecimal number, and a space is encoded as a plus (+). This function facilitates the encoding of a string and its use in the request portion of the URL, as well as the convenience of passing a variable to the next page. UrlEncode: Refers to the URL of the Web page in the Chinese characters of an encoding conversion, the most common is Baidu, Google and other search engines to enter the query, the generation of Encode Web page URL. UrlEncode generally have two kinds of traditional GB2312-based encode (Baidu, Yisou, etc.), a UTF-8-based encode (Google,Yahoo! and other uses). This tool realizes the encode and decode of two ways respectively. EnglishEncode, GB2312,%d6%d0%ce%C4 ChineseEncode, UTF-8,%e4%b8%ad%e6%96%87HTML UrlEncode encoded in an HTML file of GB2312, HTTP://www.nowamagic.net/Chinese. RAR---browser automatically converted to Http://www.nowamagic.net/%D6%D0%CE%C4.rarNote: Firefox does not support the Chinese URL for GB2312 's encode because it defaults to UTF-8 encoding to send the URL, but ftp://The protocol can. encoded as UTF-8 HTML file, http://www.nowamagic.net/Chinese. RAR---browser automatically converted to Http://www.nowamagic.net/%E4%B8%AD%E6%96%87.rarUrlEncode in PHP:1<?PHP2//GB2312 's encode3Echo UrlEncode("Chinese-_."). " \ n ";//%d6%d0%ce%c4-_.+4Echo UrlDecode("%d6%d0%ce%c4-_."). " \ n ";//Chinese-_.5Echo Rawurlencode("Chinese-_."). " \ n ";//%d6%d0%ce%c4-_.%206Echo Rawurldecode("%d6%d0%ce%c4-_."). " \ n ";//Chinese-_.7?>except-_. All non-alphanumeric characters will be replaced with a percent percent (%) followed by a two-digit hexadecimal number. The difference between UrlEncode and Rawurlencode:UrlEncodeThe space is encoded as a plus sign (+)RawurlencodeThe space is encoded as a plus sign (%20) If you want to use UTF-8 Encode, there are two ways: Save a file as UTF-8 files, directly using UrlEncode, Rawurlencode can be. Use the Mb_convert_encoding function. 1<?PHP2$url= ' http://www.nowamagic.net/Chinese. rar '; 3Echo UrlEncode(Mb_convert_encoding ($url, ' Utf-8 ', ' gb2312 '). " \ n "; 4Echo Rawurlencode(Mb_convert_encoding ($url, ' Utf-8 ', ' gb2312 '). " \ n "; 5//Http%3a%2f%2fwww.nowamagic.net%2f%e4%b8%ad%e6%96%87.rar6?>Example:01<?PHP02functionparseURL ($url="") 03{ 04$url=Rawurlencode(Mb_convert_encoding ($url, ' gb2312 ', ' utf-8 ')); 05$a=Array("%3a", "%2f", "%40"); 06$b=Array(":", "/", "@"); 07$url=Str_replace($a,$b,$url); 08return $url; 09} 10$url= "Ftp://ud03:[email protected]/Chinese/English. rar"; 11EchoparseURL ($url); 12//Ftp://ud03:[email Protected]/%d6%d0%ce%c4/%d6%d0%ce%c4.rar13?>the UrlEncode in JavaScript:%e4%b8%ad%e6%96%87-_.%20%e4%b8%ad%e6%96%87-_.%20,encodeuri does not encode the following characters: ":", "/", ";", "?", "@" and other special characters.

UrlEncode ()

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.