It can contain any of the following characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?
Any other character must be encoded using percent encoding (% hh). Each part of the URI has additional restrictions as to which characters should be represented by a percent encoded word.
It is also true that different symbols are legal at different points. For example, according to RFC 2396, unescaped '?' is legal in part of the fragment, but not in part of the path.
source share