WEBVTT

0
00:00.780 --> 00:07.320
Remember a few lectures back when we were discussing the accept-charset attribute, I used the example...

1
00:07.320 --> 00:12.060
of a user writing "theta", the symbol θ into the form.

2
00:12.350 --> 00:12.930
Do you remember that?

3
00:13.380 --> 00:18.840
And I specifically wanted to use theta, because when we use the UTF character encoding type, for example,

4
00:19.350 --> 00:23.130
you can actually see the character θ in the URL address bar.

5
00:23.340 --> 00:31.110
And the only reason this is possible, is because it is part, theta is part, of the extended ASCII character set.

6
00:31.110 --> 00:33.310
Its decimal number is 226...

7
00:33.330 --> 00:36.780
in case you're wondering, which you weren't wondering, I don't even know why I say this stuff. 🤦‍♂️

8
00:36.960 --> 00:44.130
Anyways, when I was in those lectures, I also mentioned that the URL spec states that only characters...

9
00:44.130 --> 00:51.480
that form part of the ASCII character set, are allowed to be transported in the URL bar. And this means for...

10
00:51.480 --> 00:57.290
characters that are outside of the ASCII character set, that the URL has to be amended in some way.

11
00:57.570 --> 01:01.020
And this is where URL encoding takes place.

12
01:01.050 --> 01:06.960
This is why it has to be there, because we know the ASCII character is very limited in scope.

13
01:07.260 --> 01:14.340
You and I know that a URL, the Uniform Resource Locator, is just an address of a resource on the

14
01:14.340 --> 01:14.610
Web.

15
01:14.820 --> 01:23.130
These URLs, they have a very well defined structure which was originally invented or defined or specked...

16
01:23.130 --> 01:28.250
out, by Tim Burns Lee, the inventor of the World Wide Web.

17
01:28.530 --> 01:36.030
And today, all URLs have to conform, have to follow the rules and syntax rules defined by the

18
01:36.030 --> 01:40.260
W3 Uniform Resource Identifier Specification.

19
01:41.310 --> 01:48.270
That is a mouthful! But all you need to know is that there is this spec, and browsers are obliged to follow...

20
01:48.270 --> 01:48.780
that spec.

21
01:49.080 --> 01:55.980
And in that spec it says that your URLs can only contain a subset of ASCII characters.

22
01:56.220 --> 01:59.220
And this means that many characters are not allowed in the URL.

23
01:59.850 --> 02:03.180
We also have special characters. Like what about spaces, for example?

24
02:03.450 --> 02:07.080
Well, that's exactly why we have URL encoding.

25
02:07.290 --> 02:11.940
And with these special characters, like spaces, what normally happens is that there's a token value...

26
02:11.940 --> 02:15.660
that's used, a percentage sign, followed by two characters.

27
02:15.660 --> 02:19.920
And these two characters correspond to the ASCII character hex value. 

28
02:20.130 --> 02:23.100
For example, a space is converted to %20. 

29
02:23.250 --> 02:28.380
An exclamation mark is converted to %21, and so on and so forth.

30
02:28.530 --> 02:30.500
So how do you and I encode all these values? Well...

31
02:30.510 --> 02:35.580
the good news is, my dear student, is the browser does this automatically, straight out of the box. 📦

32
02:35.910 --> 02:37.590
Let me hop over to the computer, and show you.

33
02:38.340 --> 02:39.000
So here we go.

34
02:39.000 --> 02:40.050
We're just in Chrome.

35
02:40.050 --> 02:46.410
And if I go to the URL address bar, and let's just type "gerald the giraffe". 

36
02:47.750 --> 02:48.290
That's all I've done. 

37
02:48.910 --> 02:52.810
What's going to happen when we press the enter or return key? Well, let's do it. 

38
02:55.330 --> 03:01.780
You can see that the URL has automatically encoded those special characters, those spaces that I

39
03:01.780 --> 03:02.170
typed.

40
03:02.710 --> 03:06.220
Can you see it? We've got these plus + signs. 

41
03:06.730 --> 03:10.510
And don't worry, I know I just said that spaces are converted to %20's. 

42
03:11.200 --> 03:12.160
Why is it a plus?

43
03:12.190 --> 03:13.750
Well, that's just a nuance...

44
03:13.750 --> 03:15.340
and we're going to get into that a bit later.

45
03:15.490 --> 03:21.820
But for now, just know that the URL encoding happens automatically by the browser, whether or not you

46
03:21.820 --> 03:22.840
and I like it.

47
03:24.360 --> 03:26.990
Hope that's making sense, and I'll see you in the next lecture.