Skip to content

URL Encoding

URLs can only contain a limited set of characters as defined in RFC 3986. Special characters or non-ASCII characters (e.g., German umlauts) must be encoded to avoid conflicts or misinterpretation.

What is URL Encoding?

URL encoding is a method to convert special characters in a URL into a safe format. This is essential because URLs are restricted to specific characters, such as letters (A-Z, a-z), numbers (0-9), and a few symbols (-, _, .).

Characters that do not meet this rule, such as spaces, #, or non-English letters (ä, ë, à), must be encoded. Other characters (e.g., /, ?, &) have specific meanings in URLs and can only be used as encoded values in query parameters.

Encoding replaces each character with a combination of:

  1. A percent sign (%).
  2. Two hexadecimal digits, representing the ASCII or UTF-8 value of the character.

In the context of the CodeListHub API, this primarily concerns the values and regular expressions in the URL parameters searchTerm, canonicalUri, and canonicalVersionUri.

Which Characters Must Be Encoded?

  1. Special Characters and Spaces:

    • A space becomes %20.
    • & becomes %26.
    • = becomes %3D.
    • etc.
  2. Non-English Letters (Umlauts, Accents, etc.):

    • ä becomes %C3%A4.
    • ö becomes %C3%B6.
    • à becomes %C3%A0.
    • ë becomes %C3%AB.
    • etc.
  3. Other Special Symbols:

    • # becomes %23.
    • + becomes %2B.
    • / becomes %2F.
    • etc.

Spaces

A space can also be represented by a plus sign (+) instead of %20.

Example

The following CodeListHub API example returns all document entries whose name begins with ISO:

  • Original:

    curl -X GET 'https://api.codelisthub.org/v1/documents/index?searchTerm=^ISO' -H 'accept: text/json' | ConvertFrom-Json | ConvertTo-Json
    
    curl -X GET 'https://api.codelisthub.org/v1/documents/index?searchTerm=^ISO' -H 'accept: text/json' | json_pp
    
  • With URL Encoding:

    curl -X GET 'https://api.codelisthub.org/v1/documents/index?searchTerm=%5EISO' -H 'accept: text/json' | ConvertFrom-Json | ConvertTo-Json
    
    curl -X GET 'https://api.codelisthub.org/v1/documents/index?searchTerm=%5EISO' -H 'accept: text/json' | json_pp
    

Here, the circumflex ^ in the regular expression has been encoded as %5E.

Tool

The following tool helps you to encode any value. To do this, type the text into the first text field and click on ‘Encode’.

You can see the URL encoded result here:

Encoding Tables

Latin Characters with Accents and Diacritics

Character URL Encoding Character URL Encoding
À %C3%80 Á %C3%81
 %C3%82 à %C3%83
Ä %C3%84 Å %C3%85
Æ %C3%86 Ç %C3%87
È %C3%88 É %C3%89
Ê %C3%8A Ë %C3%8B
Ì %C3%8C Í %C3%8D
Î %C3%8E Ï %C3%8F
Ð %C3%90 Ñ %C3%91
Ò %C3%92 Ó %C3%93
Ô %C3%94 Õ %C3%95
Ö %C3%96 Ø %C3%98
Ù %C3%99 Ú %C3%9A
Û %C3%9B Ü %C3%9C
Ý %C3%9D Þ %C3%9E
ß %C3%9F à %C3%A0
á %C3%A1 â %C3%A2
ã %C3%A3 ä %C3%A4
å %C3%A5 æ %C3%A6
ç %C3%A7 è %C3%A8
é %C3%A9 ê %C3%AA
ë %C3%AB ì %C3%AC
í %C3%AD î %C3%AE
ï %C3%AF ð %C3%B0
ñ %C3%B1 ò %C3%B2
ó %C3%B3 ô %C3%B4
õ %C3%B5 ö %C3%B6
ø %C3%B8 ù %C3%B9
ú %C3%BA û %C3%BB
ü %C3%BC ý %C3%BD
þ %C3%BE ÿ %C3%BF

Special Characters

Character Meaning URL Encoding
Space %20
! Exclamation mark %21
" Double quotation mark %22
# Hash symbol %23
$ Dollar sign %24
% Percent sign %25
& Ampersand %26
' Apostrophe %27
( Open parenthesis %28
) Close parenthesis %29
* Asterisk %2A
+ Plus sign %2B
, Comma %2C
- Hyphen %2D
. Period %2E
/ Forward slash %2F
: Colon %3A
; Semicolon %3B
< Less-than sign %3C
= Equal sign %3D
> Greater-than sign %3E
? Question mark %3F
@ At sign %40
[ Open square bracket %5B
\ Backslash %5C
] Close square bracket %5D
^ Caret (circumflex) %5E
_ Underscore %5F
` Backtick %60
{ Open curly brace %7B
| Vertical bar %7C
} Close curly brace %7D
~ Tilde %7E