URI Encoding Charset



Published: 2017-08-06 22:06:14 +0000
Categories: Misc,

Description

Quick reference for mapping RFC 3986 encoded URI characters back to ASCII characters

Similar to

Based On

import urllib
cols = ["value","char","urlencoded", "value2", "char2","urlencoded2" ]
hardcode = [
    '^@','^A','^B','^C','^D','^E','^F','^G',
    '^H','^I','^J','^K','^L','^M','^N','^O',
    '^P','^Q','^R','^S','^T','^U','^V','^W',
    '^X','^Y','^Z','^[','^\\','^]','^^','^_',
    '[space]']

rows = []
for i in range(64):
    r = {
        "value" : i,
        "char" : chr(i),
        "urlencoded" : urllib.quote_plus(chr(i)),
        "value2" : i + 65,
        "char2" : chr(i+65),
        "urlencoded2" : urllib.quote_plus(chr(i+65)),
    }

    if i < 33:
        r['char'] = hardcode[i]

    if i == 32:
        r['urlencoded'] = "+ or %20"

    if i+65 == 127:
        r['char2'] = 'DEL'

    rows.append(r)

print make_table(cols,rows)

Snippet

|-------------------------------------------------------------|
| value | char    | urlencoded | value  | char  | urlencoded  |
|-------------------------------------------------------------|
| 0     | ^@      | %00        | 65     | A     | A           |
| 1     | ^A      | %01        | 66     | B     | B           |
| 2     | ^B      | %02        | 67     | C     | C           |
| 3     | ^C      | %03        | 68     | D     | D           |
| 4     | ^D      | %04        | 69     | E     | E           |
| 5     | ^E      | %05        | 70     | F     | F           |
| 6     | ^F      | %06        | 71     | G     | G           |
| 7     | ^G      | %07        | 72     | H     | H           |
| 8     | ^H      | %08        | 73     | I     | I           |
| 9     | ^I      | %09        | 74     | J     | J           |
| 10    | ^J      | %0A        | 75     | K     | K           |
| 11    | ^K      | %0B        | 76     | L     | L           |
| 12    | ^L      | %0C        | 77     | M     | M           |
| 13    | ^M      | %0D        | 78     | N     | N           |
| 14    | ^N      | %0E        | 79     | O     | O           |
| 15    | ^O      | %0F        | 80     | P     | P           |
| 16    | ^P      | %10        | 81     | Q     | Q           |
| 17    | ^Q      | %11        | 82     | R     | R           |
| 18    | ^R      | %12        | 83     | S     | S           |
| 19    | ^S      | %13        | 84     | T     | T           |
| 20    | ^T      | %14        | 85     | U     | U           |
| 21    | ^U      | %15        | 86     | V     | V           |
| 22    | ^V      | %16        | 87     | W     | W           |
| 23    | ^W      | %17        | 88     | X     | X           |
| 24    | ^X      | %18        | 89     | Y     | Y           |
| 25    | ^Y      | %19        | 90     | Z     | Z           |
| 26    | ^Z      | %1A        | 91     | [     | %5B         |
| 27    | ^[      | %1B        | 92     | \     | %5C         |
| 28    | ^\      | %1C        | 93     | ]     | %5D         |
| 29    | ^]      | %1D        | 94     | ^     | %5E         |
| 30    | ^^      | %1E        | 95     | _     | _           |
| 31    | ^_      | %1F        | 96     | `     | %60         |
| 32    | [space] | + or %20   | 97     | a     | a           |
| 33    | !       | %21        | 98     | b     | b           |
| 34    | "       | %22        | 99     | c     | c           |
| 35    | #       | %23        | 100    | d     | d           |
| 36    | $       | %24        | 101    | e     | e           |
| 37    | %       | %25        | 102    | f     | f           |
| 38    | &       | %26        | 103    | g     | g           |
| 39    | '       | %27        | 104    | h     | h           |
| 40    | (       | %28        | 105    | i     | i           |
| 41    | )       | %29        | 106    | j     | j           |
| 42    | *       | %2A        | 107    | k     | k           |
| 43    | +       | %2B        | 108    | l     | l           |
| 44    | ,       | %2C        | 109    | m     | m           |
| 45    | -       | -          | 110    | n     | n           |
| 46    | .       | .          | 111    | o     | o           |
| 47    | /       | %2F        | 112    | p     | p           |
| 48    | 0       | 0          | 113    | q     | q           |
| 49    | 1       | 1          | 114    | r     | r           |
| 50    | 2       | 2          | 115    | s     | s           |
| 51    | 3       | 3          | 116    | t     | t           |
| 52    | 4       | 4          | 117    | u     | u           |
| 53    | 5       | 5          | 118    | v     | v           |
| 54    | 6       | 6          | 119    | w     | w           |
| 55    | 7       | 7          | 120    | x     | x           |
| 56    | 8       | 8          | 121    | y     | y           |
| 57    | 9       | 9          | 122    | z     | z           |
| 58    | :       | %3A        | 123    | {     | %7B         |
| 59    | ;       | %3B        | 124    | |     | %7C         |
| 60    | <       | %3C        | 125    | }     | %7D         |
| 61    | =       | %3D        | 126    | ~     | %7E         |
| 62    | >       | %3E        | 127    | DEL   | %7F         |
| 63    | ?       | %3F        |        |       |             |
---------------------------------------------------------------

Keywords

URL, URI, Encoding, RFC 3986, RFC 1738, RFC 2396, encode, escaped,

Latest Posts

Urldecode string (LUA)
FFMPEG Convert YUV444p to YUV420p (BASH)
Forcing FFMPEG to honour segment length in HLS Stream Creator (BASH)
Force CURL to place request to a specific IP (BASH)
Set a variable only if it is undefined (Javascript)
Ignore query string with Nginx caching proxy (NGinx)
Get breakdown of UK and non-UK votes for a Parliamentary Petition (Python)
Decompress Mozilla Firefox jsonlz4 bookmark backup files (Python)
Setting Git author details for a single repo (Git)
Checking Virtual Machine Resource Allocations with Libvirt (BASH)

Copyright © 2019 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk and snippets.6zdgh5a5e6zpchdz.onion