URI Encoding (or Percent Encoding) applies to attributes of type URI and URIs.
Important: After any required URI-encoding (see below), any remaining ampersand (&) characters must then be escaped as &
(or &) before inserting the URI into the attribute. Also, if using a pair of single quote (') characters to
delimit the attribute, any single quotes within the attribute value itself must be escaped as '
(or ' if compatibility with HTML isn't necessary - see Character Entities Predefined by XML 1.0).
These requirements are necessary to comply with the constraints of the
*XML 1.0 Specification.
The characters A-Z, a-z, 0-9, hyphen/dash (-), underscore (_), full stop (.) and tilde (~) should be used without encoding in a URI. Others may have to be encoded, depending upon their purpose in the URI.
Characters within a URI may be grouped into the following categories:
See *RFC 3986: URI Generic Syntax (Section 2) for more information on the structure of URIs.
The table below shows how common characters should be URI-encoded.
| Unicode Character Name | Char | URI-encoding | Other Name |
|---|---|---|---|
| SPACE | %20 or + | - | |
| EXCLAMATION MARK | ! | %21 | - |
| QUOTATION MARK | " | %22 | Double Quote |
| NUMBER SIGN | # | %23 | Hash |
| DOLLAR SIGN | $ | %24 | - |
| PERCENT SIGN | % | %25 | Percentage Sign |
| AMPERSAND | & | %26 | - |
| APOSTROPHE | ' | %27 | Single Quote |
| LEFT PARENTHESIS | ( | %28 | Left Bracket |
| RIGHT PARENTHESIS | ) | %29 | Right Bracket |
| ASTERISK | * | %2A | Star |
| PLUS SIGN | + | %2B | - |
| COMMA | , | %2C | - |
| SOLIDUS | / | %2F | Slash |
| COLON | : | %3A | - |
| SEMICOLON | ; | %3B | - |
| LESS-THAN SIGN | < | %3C | - |
| EQUALS SIGN | = | %3D | - |
| GREATER-THAN SIGN | > | %3E | - |
| QUESTION MARK | ? | %3F | - |
| COMMERCIAL AT | @ | %40 | At Sign |
| LEFT SQUARE BRACKET | [ | %5B | - |
| REVERSE SOLIDUS | \ | %5C | Backslash |
| RIGHT SQUARE BRACKET | ] | %5D | - |
| CIRCUMFLEX ACCENT | ^ | %5E | Caret |
| GRAVE ACCENT | ` | %60 | Backtick |
| LEFT CURLY BRACKET | { | %7B | Left Brace |
| VERTICAL LINE | | | %7C | Pipe |
| RIGHT CURLY BRACKET | } | %7D | Right Brace |
| POUND SIGN | £ | %C2%A3 (UTF-8), %A3 (ISO-8859-1) | - |