Note:this is a companion problem to the System Design problem:design tinyurl.
TinyURL is a URL shortening service where you enter a URL such as and https://leetcode.com/problems/design-tinyurl it returns a short URL such as http://tinyurl.com/4e9
Basic concepts of 1.URL codingURLs can only be sent over the Internet using the US-ASCII character set. Because URLs often contain characters outside of the ASCII collection, URLs must be converted to valid ASCII formats. URL encoding uses a "%"
In the process of passing parameters in js in the front and back end, garbled characters are easy to appear if it is Chinese, so it is best to encode it first.
1. Add the encoding method of the entire website to the web. config file.
In this way,
Although escape (), encodeuri (), and encodeuricomponent () methods can affect the URL integrity
Character filtering. But the latter two is to convert the string to the UTF-8 way to transfer, solve the problem caused by inconsistent page
Urlencode (PHP4, PHP5) urlencode & nbsp; & mdash; & nbsp; URL string description string & nbsp; urlencode & nbsp; (& nbsp; string & nbsp; $ str & nbsp;) This function allows you to encode a string and use it in the request section of the URL.
(PHP 4,
URL encoding is an encoding used by HTTP to transmit various parameters at a single URL clock. This encoding will encode special characters (such as ' = ', ' & ', ' + ') in the form of '% ', where is the hexadecimal representation of the character.
Special character escaping encoding in URL URLsDecember 29, 2017 09:10:57Hits:Special character escaping encoding in URL URLsCharacter-URL encoded valueSpaces-%20"-%22#-%23%-%25&-%26(-%28)-%29+-%2B,-%2c/-%2F:-%3a; -%3b=-%3d>-%3e? -%3f@-%40\-%5C|
Http://www.imkevinyang.com/2009/08/%E8%AF%A6%E8%A7%A3javascript%E4%B8%AD%E7%9A%84url%E7%BC%96%E8%A7%A3%E7%A0%81.htmlSummaryIn this paper, we mainly introduce the related problems of URI codec, and explain in detail which characters in URL coding
For example, in a URL parameter string, the Key=value key value is used to pass the argument, and the key value pairs are separated by & symbols, such as/s?q=abc&ie=utf-8. If your value string contains = or, it is bound to result in a server parsing
The C language implementation of URL encode and URL decode, encodedecode
Reprinted from: http://blog.csdn.net/langeldep/article/details/6264058
The code in this article is modified from the PHP code, and only two functions are retained.
Int
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.