This is such a complicated topic, and that's why it's so important for me to spend more time on it...
before we move on.
I want to look at this URL Encoding and I want us to look at the example we had by using the "theta"
character.
Remember what we're doing here...
we're looking at what happens when the page's charset
does not contain a character that's entered into the form.
There's our form. We defined the accept-charset attribute as being ISO-1859-1. And our user
typed in a character outside of this range.
The user typed in a character of theta.
This theta character does not appear in the ISO encoding.
So this means trying to encode it with the ISO encoding type will present a significant problem to the
browser.
And as I discussed previously, each browser, each different browser will handle this problem differently.
Chrome will produce the following...
GET url.
We've seen this. And at first glance you might think this is so odd and weird, but once you understand...
how encoding works, you'll know exactly why this URL looks the way it does.
So let's jump into it.
Let's discuss why this URL looks the way it does before we get into the nitty gritty.
The first thing I want you to notice, which is quite straightforward, is that all your form data...
is sent to the server after that question mark ? sign in the URL, and every variable you send to the server...
will be displayed as a "name=value" pair, separated by an equal sign.
OK, so your variables name is to the left of the equal and your variables values to the right of that
equals sign.
Pretty straightforward, right?
Whaaaat 😕! Why do we have this question mark and these equal signs in the URL?
Are we going to be talking more about this later...
but just as a bit of a spoiler alert, this is what's known as URL encoding that the browser implements.
The browser has to make sure that all the characters in that URL are (a) understood universally all of
the browsers and servers and (b), that they are safe characters, that they don't conflict with your
code, for example.
And as we'll discuss a bit later, I'm going to have a dedicated, um, lecture or lectures on URL Encoding...
so don't worry yet. For now,
remember that URLs can only be sent over the web using the ASCII character set.
And since URLs often contain characters that are outside of this ASCII character set, the URL has to...
be converted into valid ASCII format.
Makes sense, right?
So URL encoding just takes unsafe characters and puts a percentage sign first, with two hexadecimal...
characters after it. Whew,
abut this now poses another problem.
What is hexadecimal digits?
I don't want to get into detail about that here, but just know as humans, we love decimal, we love...
using our 10 fingers 🖐🖐, which means in a decimal system, each character can represent a number from 0
to 9.
Makes sense to us as humans.
At a machine's fundamental level, the machine understands binary.
It uses a completely different system, 1s and 0s.
And when we are talking hexadecimal, we are using a completely different system. In a hexadecimal system...
a single character can represent 0 to 15 unique values. And hexadecimal just very widely used...
by computers and programmers.
It's just the way it is.
It's just has been around for a very long time.
Let's jump back into the lecture.