Шаблон:Encodelink

Мавод аз Википедиа — донишномаи озод

{{{2}}}

The Template:Encodelink generates a weblink, of the form "[http:__]" but with the URL address encoded to handle special characters (such as spaces or plus sign "+" or square brackets "[_]" in the URL). Parameter 1 is the URL, and parameter 2 is the link-text to display.

Usage: {{encodelink|http://x.com|my link}} → [http://x.com my link]   shows as:  my link

If a URL contains a slash, then the first 42 characters are copied verbatim, and the remainder of the URL is encoded for special characters. Each special character is encoded as %-notation, where '+' is %2B, each left square bracket '[' is %5B, or each right square bracket ']' is %5D.

Examples[вироиши манбаъ]

The following example uses special characters:

  • {{encodelink|http://en.wikipedia.org/w/index.php?title=2+2=4&action=edit|Edit 2+2=4}} → [http://en.wikipedia.org/w/index.php?title=2%2B2%3D4&action=edit Edit 2+2=4] shows as:  Edit 2+2=4

Note that although the special characters are encoded, as percent notation, they might be considered invalid characters for a particular website. Each website has its own rules for the allowable valid names or options. Also, if part of the URL is already encoded, then it will become double-encoded, so a slash "/" already encoded as "%2F" will become "%252F" where the percent sign '%' is %25.

See also[вироиши манбаъ]