We're going to be getting into this later, but just know that the question mark, and that equals sign, these...
are known as "reserved characters" for URL encoding. Alright,
well this is pretty straightforward...
so let's move on.
Let's get into the more complicated bit...
and that is, what is this about? (sound effect: what did you say?) Well, that is a brilliant question, my dear student...
and that's what I want to talk about now.
Firstly, the Chrome browser knows that it cannot represent theta in the ISO charset...
and so it doesn't even try and represented in that character encoding type, because it can't, it doesn't exist.
So what does it do then?
Well, the default action by this browser, is that it's going to transform the characters - that theta character -
into what's known as "numeric character references".
And as I mentioned before, other browsers may behave differently, opting to generate question marks...
or even to prevent the input being inserted in the URL entirely.
It just depends on the browser.
I know we're doing a lot of quick cuts here, but this is very, very important.
But I just want to mention here that remember in the previous lecture when we defined the accept-charset encoding...
type as utf-8? What happened when we used theta in that instance?
Well, that's right...
in that case, we actually saw that theta character in the URL itself.
And the reason is, is that it's a ASCII safe character.
And that just meant that the browser didn't have to encode that character into a numerical character
reference.
And as I mentioned, it's because that theta character could just be encoded directly into the URL in...
its correct encoding type.
But now that we've specified an encoding type that does not recognize theta, the browser has to make...
another plan. It has to do something right? It can't just do nothing.
And that's what it's trying to do,
and that's why it converts it into a numerical character reference.
OK, so this is the first thing you need to realize is that when the character is outside of that encoding...
type, this browser, Chrome, will try and convert that character into a numeric character reference.
The important thing to know, though, is that the browser would not have to do this if that character
was, in fact part of the encoding type we specify.
So this is now something else that has to happen because it doesn't fit within the encoding type.
It has to convert that character into a numeric character reference.
"Well, what does that mean, Clyde?"
Well, it means that each value is encoded into this format - an "&", a "#", a "D" and a ";".
And that "D" represents the character's decimal codepoint value in the Unicode character set.
This is important and this is the distinguishing difference when a character's outside of the encoding
type.
If the character is in the encoding type, then what's encoded in the URL is the hexadecimal format
of that specific character.
Here, that doesn't exist because it's not in the encoding type...
therefore it has to be converted into a numeric character reference, and that is stored by the browser as a decimal
codepoint value.
And before we move on, I just want to remind you that there is a difference between numerical character references,
which is what the browser is doing now when a character is not within that accept-charset type, and...
an external character set a.k.a. the charset. There are differences between the two. Very quickly, a...
numerical character reference, or NCR for short, is just a common markup construct for HTML, and they're used in order
to represent characters that cannot be URL encoded.
And remember in our example here, that theta, that character cannot be URL encoded because
it doesn't exist in encoding type that we've specified.
That's why this NCR has been the fallback.
With an external character set, for example, this is chosen by us, by the web author, by the programmer.
And why do we define it?
Well, we define it so we have complete control over what characters we want to allow our browser to accept.
So, in short, the numerical character reference is a way for browsers to understand what the characters
mean. The external characters set, the charset attribute,
well, that's just an encoding that you and I can specify to both browsers and servers.
So that's key differences between the two. But enough of this already.
Let's jump back into why the URL looks like it does.
Remember, we've got this format right.
This is the numerical character reference format. And that "D" stores whatever value you are dealing with...
in the decimal codepoint value.
So what is the theta value?
Well, the theta sign has a value of 952 in the browser's numerical character set.
This is going to result in what URL?
Just take our URL, that standard & # D and ;...
and now we can replace the D, right.
We can replace that D with the value of 952. There we go,
this is what it looks like.
Okay, but this doesn't look like our URL previously, does it?
We don't have all this weird percentage signs and numbers.
That's right.
We're not quite done yet because up to this point...
no URL encoding has taken place.
Whaaat? I know it sounds strange...
just remember that URL encoding does have to take place at some point.
Every time a URL is sent to a server, there are rules that the browser has to abide by.
And the major rule there is that all the characters in that URL has to form part of the extended ASCII
character set.
That's just a bit of FYI.
Don't worry, we're going to be talking more about this later.
So for now, let's look at our URL.
But now we're not concerned about the number 952 are we? We know what that means...
we know that that is the numerical character codepoint in the browser for the theta character.
Simple enough.
Let's now deal with those other characters, the &, #, and the ; ...
only now does URL encoding take place,
at this point in time.
The URL encoding rules specify that all characters have to be converted into the hexadecimal equivalents.
And again, I don't want to get into massive detail about how this conversion takes place, but hexadecimal
equivalents of the &, # and ;, are the following...
let me make this more clear by changing the colors of each so you can see where they have gone and what
their hexadecimal values are.
Does that make sense? The & is %27, the # is %23 and...
that ; is %3B. Whew, I know. We are covering very advanced things, and I hope you are following
along.
But you know what's weird, is that this doesn't really solve our problem.