All right, so here we are.
I just want to discuss what happens when we include a character that is not specified in the encoding...
type that we tell the browser that we accept.
That's quite interesting.
Let's just start off by creating a very simple form. The " "action" we don't need...
and we're going to be getting into the action attribute later.
Now, let me just show you a GET request.
I want us to have our attribute, "accept-charset".
Let's just start of by saying it's utf-8.
Very simple. Then what I want to do is I want us to use the character theta.
Theta, I've just copied it from a Word document...
that's all I've done.
This is theta. And the reason I'm using theta is that this is not included in the ISO character.
So I just want to show you what happens. Anyway...
now I want us to have our input here.
The next thing we need on our input is a name...
otherwise it won't be submitted to the server.
And let's just give it a name of "yourName".
Very simple. And then lastly, if we save this and you look at our browser right now, we don't have
a submit button.
So all I want to do is create a submit button. We're going to see this later on in the course...
but for now, just know we can define another type on this input element being "submit".
And we can give it a value of "submit me", or just "submit", to keep it simple.
So far, so good, right?
And what happens if we do type theta into this text box? Let me just zoom in a little bit so you can...
see, we're putting theta in here.
If we click submit, you can see in the URL, you've literally got the name of our variable, which...
we've called yourName, and we've assigned that to the value of theta.
And what's really cool, is that this is allowed because we've specified utf-8 as our encoding type...
and as we've seen, it's got over 1.1 million values that it can represent, or characters...
I should say. And theta is definitely one of them.
The other thing you should bear in mind, is that the "method" and our "accept-charset" attributes here, are...
the default values.
So actually we could delete everything...
we could refresh the page, let me just delete the URL...
put in theta again, click submit, and we get exactly the same result.
So this only becomes important, of course, when you want to start messing around with the accept-charset
attribute, which we're going to do now, by the way.
So let's define our character encoding now, accept-charset...
but now this time, I want us to use ISO.
Nowwwww things are going to get interesting. Let's delete the URL, so it's very clean. Let's say the...
use types theta, and let the user now click submit.
What do you think is going to happen?
We'll look at that, we get thrown back to us, a weird looking URL with a whole lot of percentage...
signs.
And it's very hard for the server, if not impossible sometimes, to actually determine what the character...
encoding of such a request was.
Why?
Because the server usually assumes that it is the same as the encoding the page containing the form...
was submitted in.
In other words, the server is going to assume in our instance here, that the encoding type is utf-8,
and it's going to try and decode that information using utf-8, and it's not going to work.
So to cut a long story short, once you start adding characters outside of your defined character...
encoding type...
a lot of strange things start to happen.
And it's also very browser dependent, I might add.
Different browsers do different things.
Browsers might replace the unsupported characters with useless question marks,
they may attempt to fix the characters, for example, smart quotes to regular quotes...
some browsers might replace the character with a character entity reference, or some browsers might
send it anyway as a different character encoding that what you specified in the form, mixing it in with...
the original encoding of your entire document. Whew, I know, I've just said a lot.
And bear in mind the example we looked at, was on Chrome...
and what Chrome has tried to do, is it's trying to replace the unknown character with a character entity
reference in the browser.
I know that might be a bit confusing.
Don't worry.
In the next lecture, let me just explain a bit more exactly why we see these weird numbers with percentage...
signs everywhere.
This is really, really interesting and it is very advanced.
And I know we are very early on in the course, so I don't want to scare you. If you're not quite following
me...
it's okay.
We're going to get through it together. I'll see you in the next lecture.