Remember a few lectures back when we were discussing the accept-charset attribute, I used the example...
of a user writing "theta", the symbol θ into the form.
Do you remember that?
And I specifically wanted to use theta, because when we use the UTF character encoding type, for example,
you can actually see the character θ in the URL address bar.
And the only reason this is possible, is because it is part, theta is part, of the extended ASCII character set.
Its decimal number is 226...
in case you're wondering, which you weren't wondering, I don't even know why I say this stuff. 🤦‍♂️
Anyways, when I was in those lectures, I also mentioned that the URL spec states that only characters...
that form part of the ASCII character set, are allowed to be transported in the URL bar. And this means for...
characters that are outside of the ASCII character set, that the URL has to be amended in some way.
And this is where URL encoding takes place.
This is why it has to be there, because we know the ASCII character is very limited in scope.
You and I know that a URL, the Uniform Resource Locator, is just an address of a resource on the
Web.
These URLs, they have a very well defined structure which was originally invented or defined or specked...
out, by Tim Burns Lee, the inventor of the World Wide Web.
And today, all URLs have to conform, have to follow the rules and syntax rules defined by the
W3 Uniform Resource Identifier Specification.
That is a mouthful! But all you need to know is that there is this spec, and browsers are obliged to follow...
that spec.
And in that spec it says that your URLs can only contain a subset of ASCII characters.
And this means that many characters are not allowed in the URL.
We also have special characters. Like what about spaces, for example?
Well, that's exactly why we have URL encoding.
And with these special characters, like spaces, what normally happens is that there's a token value...
that's used, a percentage sign, followed by two characters.
And these two characters correspond to the ASCII character hex value.
For example, a space is converted to %20.
An exclamation mark is converted to %21, and so on and so forth.
So how do you and I encode all these values? Well...
the good news is, my dear student, is the browser does this automatically, straight out of the box. 📦
Let me hop over to the computer, and show you.
So here we go.
We're just in Chrome.
And if I go to the URL address bar, and let's just type "gerald the giraffe".
That's all I've done.
What's going to happen when we press the enter or return key? Well, let's do it.
You can see that the URL has automatically encoded those special characters, those spaces that I
typed.
Can you see it? We've got these plus + signs.
And don't worry, I know I just said that spaces are converted to %20's.
Why is it a plus?
Well, that's just a nuance...
and we're going to get into that a bit later.
But for now, just know that the URL encoding happens automatically by the browser, whether or not you
and I like it.
Hope that's making sense, and I'll see you in the next lecture.