WEBVTT

0
00:09.260 --> 00:15.460
This is such a complicated topic, and that's why it's so important for me to spend more time on it...

1
00:15.620 --> 00:16.070
before we move on. 

2
00:16.460 --> 00:23.560
I want to look at this URL Encoding and I want us to look at the example we had by using the "theta"

3
00:23.720 --> 00:24.240
character.

4
00:25.010 --> 00:26.600
Remember what we're doing here...

5
00:26.720 --> 00:29.540
we're looking at what happens when the page's charset

6
00:29.540 --> 00:33.680
does not contain a character that's entered into the form.

7
00:35.290 --> 00:42.460
There's our form. We defined the accept-charset attribute as being ISO-1859-1. And our user

8
00:42.460 --> 00:45.100
typed in a character outside of this range.

9
00:46.150 --> 00:49.420
The user typed in a character of theta.

10
00:49.660 --> 00:53.830
This theta character does not appear in the ISO encoding.

11
00:54.010 --> 01:01.390
So this means trying to encode it with the ISO encoding type will present a significant problem to the

12
01:01.390 --> 01:01.920
browser.

13
01:02.260 --> 01:07.900
And as I discussed previously, each browser, each different browser will handle this problem differently.

14
01:08.320 --> 01:10.270
Chrome will produce the following...

15
01:10.630 --> 01:11.650
GET url.

16
01:12.640 --> 01:18.700
We've seen this. And at first glance you might think this is so odd and weird, but once you understand...

17
01:18.700 --> 01:23.230
how encoding works, you'll know exactly why this URL looks the way it does.

18
01:23.500 --> 01:24.430
So let's jump into it.

19
01:24.430 --> 01:28.510
Let's discuss why this URL looks the way it does before we get into the nitty gritty.

20
01:28.520 --> 01:33.880
The first thing I want you to notice, which is quite straightforward, is that all your form data...

21
01:33.880 --> 01:41.530
is sent to the server after that question mark ? sign in the URL, and every variable you send to the server...

22
01:41.530 --> 01:47.460
will be displayed as a "name=value" pair, separated by an equal sign.

23
01:47.890 --> 01:53.320
OK, so your variables name is to the left of the equal and your variables values to the right of that

24
01:53.320 --> 01:53.850
equals sign.

25
01:54.670 --> 01:56.050
Pretty straightforward, right?

26
01:57.640 --> 02:02.950
Whaaaat 😕! Why do we have this question mark and these equal signs in the URL?

27
02:02.950 --> 02:05.800
Are we going to be talking more about this later...

28
02:06.310 --> 02:13.870
but just as a bit of a spoiler alert, this is what's known as URL encoding that the browser implements.

29
02:14.140 --> 02:20.380
The browser has to make sure that all the characters in that URL are (a)  understood universally all of

30
02:20.380 --> 02:25.300
the browsers and servers and (b), that they are safe characters, that they don't conflict with your

31
02:25.300 --> 02:26.310
code, for example.

32
02:26.680 --> 02:32.420
And as we'll discuss a bit later, I'm going to have a dedicated, um, lecture or lectures on URL Encoding...

33
02:32.440 --> 02:35.130
so don't worry yet. For now, 

34
02:35.140 --> 02:41.290
remember that URLs can only be sent over the web using the ASCII character set.

35
02:41.590 --> 02:48.910
And since URLs often contain characters that are outside of this ASCII character set, the URL has to...

36
02:48.910 --> 02:51.970
be converted into valid ASCII format.

37
02:52.540 --> 02:53.350
Makes sense, right?

38
02:53.800 --> 03:01.900
So URL encoding just takes unsafe characters and puts a percentage sign first, with two hexadecimal...

39
03:02.170 --> 03:03.550
characters after it. Whew,

40
03:04.240 --> 03:06.040
abut this now poses another problem.

41
03:06.040 --> 03:07.650
What is hexadecimal digits?

42
03:07.960 --> 03:13.480
I don't want to get into detail about that here, but just know as humans, we love decimal, we love...

43
03:13.480 --> 03:19.720
using our 10 fingers 🖐🖐, which means in a decimal system, each character can represent a number from 0

44
03:19.720 --> 03:20.200
to 9.

45
03:20.590 --> 03:22.330
Makes sense to us as humans.

46
03:22.330 --> 03:26.440
At a machine's fundamental level, the machine understands binary.

47
03:26.660 --> 03:29.620
It uses a completely different system, 1s and 0s.

48
03:29.950 --> 03:36.310
And when we are talking hexadecimal, we are using a completely different system. In a hexadecimal system...

49
03:36.340 --> 03:43.480
a single character can represent 0 to 15 unique values. And hexadecimal just very widely used...

50
03:43.990 --> 03:45.340
by computers and programmers.

51
03:45.550 --> 03:46.270
It's just the way it is.

52
03:46.270 --> 03:47.770
It's just has been around for a very long time.

53
03:48.220 --> 03:49.350
Let's jump back into the lecture.