WEBVTT

0
00:00.870 --> 00:06.900
Hey, I'm super, super amped because now we're going to be getting into some of the meaty stuff when

1
00:06.900 --> 00:07.860
it comes to URLs.

2
00:07.890 --> 00:13.350
The first thing I want to say is that URLs can understand hexadecimal values.

3
00:13.800 --> 00:14.640
"What does that mean,

4
00:14.760 --> 00:15.210
Clyde?"

5
00:15.240 --> 00:21.660
Well, it just means that any character typed into a URL can be replaced with hexadecimal encoding for

6
00:21.690 --> 00:22.950
that character.

7
00:22.980 --> 00:31.890
For example, if we type "googl%65.com", then that can be used to get to google.com because

8
00:31.890 --> 00:35.610
65 is the hex encoding for the letter e.

9
00:35.940 --> 00:42.120
In other words, when you type that into the browser, the browser is going to swap the %65

10
00:42.120 --> 00:44.850
for the character "e" and it's going to send it on.

11
00:45.030 --> 00:45.840
What ðŸ™„?

12
00:45.840 --> 00:46.170
I know.

13
00:46.170 --> 00:47.370
That's so weird, right?

14
00:47.400 --> 00:48.490
Don't believe me?

15
00:48.510 --> 00:51.630
Let's hop on to the browser and let me quickly show you.

16
00:52.050 --> 00:57.960
So let me prove to you that a URL can understand both hex and ASCII characters.

17
00:57.960 --> 01:00.120
They kind of go hand-in-hand.

18
01:00.150 --> 01:04.930
You've got hex on the one hand and you've got Ascii on the other hand.

19
01:04.930 --> 01:10.330
And although they're two separate things, the URL understands both Hex and ASCII. 

20
01:11.500 --> 01:12.400
Good girls.

21
01:13.180 --> 01:17.050
Let me make this screen a bit bigger, and let's just type in the address bar

22
01:17.200 --> 01:18.130
Google...

23
01:18.340 --> 01:24.130
but now instead of writing "e", I want to write %65 as I just said in the lecture.

24
01:24.130 --> 01:32.050
And if we do that, and I hit return, the browser automatically converts that hex value into a character,

25
01:32.050 --> 01:34.630
an ASCII character, to be specific.

26
01:34.660 --> 01:35.350
Got it?

27
01:35.380 --> 01:36.670
Let's jump back to the lecture.

28
01:37.420 --> 01:38.080
There you go.

29
01:38.110 --> 01:39.190
You saw it in action.

30
01:39.190 --> 01:43.120
I'm not making these things up. But most people will just move on from here,

31
01:43.120 --> 01:43.510
right?

32
01:43.510 --> 01:49.630
And I don't want to. I want us to understand Hex. But what is Hex,

33
01:49.630 --> 01:50.820
you may be thinking?

34
01:50.830 --> 01:53.050
And that is a very good question.

35
01:53.230 --> 01:57.250
It's very, very important to understand the fundamentals before you start getting more advanced in

36
01:57.250 --> 02:04.780
your programming career. And don't get intimidated because hexadecimal is just a way of writing values.

37
02:04.780 --> 02:12.560
In fact, it's no different from the one we use every day, and that is the decimal system.

38
02:12.560 --> 02:19.260
Decimal is base ten and it's great for us humans. And it was designed that way because we've got 10 fingers,

39
02:19.260 --> 02:26.460
so it makes sense that it's base ten with decimal - we can use ten unique digits to represent large

40
02:26.460 --> 02:28.170
values or small values.

41
02:28.170 --> 02:32.310
And I bet you can already tell me what those ten unique digits are.

42
02:32.340 --> 02:33.180
Can you?

43
02:33.840 --> 02:34.620
That's right.

44
02:34.950 --> 02:36.420
0 to 9.

45
02:37.200 --> 02:44.250
It's very unique, it's base 10 because there are 10 unique values and they can be combined to represent

46
02:44.280 --> 02:47.550
huge numbers and teeny weeny little values.

47
02:47.910 --> 02:48.270
Okay,

48
02:48.270 --> 02:48.920
got it?

49
02:48.930 --> 02:56.220
So, similar to decimal, hex just combines digits to create large and small numbers.

50
02:56.220 --> 02:58.730
Well then, how is it different to decimal?

51
02:58.740 --> 03:03.330
Well, hex doesn't use a set of only 10 digits.

52
03:03.360 --> 03:04.980
Hex is more powerful.

53
03:04.980 --> 03:08.400
Hex uses a set of 16 unique digits.

54
03:08.610 --> 03:10.560
What digits does it use?

55
03:10.590 --> 03:15.530
Well, it uses 0 to 9, just like our fingers, just like decimal.

56
03:15.530 --> 03:19.700
And that represents 10 unique digits, ten unique values.

57
03:19.700 --> 03:28.670
But over and above decimal, hex also uses the letters A to F, which represents another six unique digits.

58
03:28.670 --> 03:33.320
So, you combine that and we've got Hex, which is base 16.

59
03:33.920 --> 03:35.750
"Okay, Clyde it's base 16,

60
03:35.750 --> 03:37.160
but what does that really mean?

61
03:37.160 --> 03:38.750
Like, I still don't get it."

62
03:38.780 --> 03:39.680
Well, that's okay.

63
03:39.680 --> 03:42.200
Let me try and show you in a slightly different way.

64
03:42.230 --> 03:48.830
Let me pick this stone up, throw it at the screen ... and let's just start from a blank slate.

65
03:49.310 --> 03:53.930
Let's say we've got a decimal system and a hex system, right?

66
03:53.930 --> 03:58.220
And we want to represent 16 unique values.

67
03:58.460 --> 04:00.080
Well, how can we do that with decimal?

68
04:00.710 --> 04:07.550
Well, very simply, we can just represent 16 unique values from writing the number zero all the way

69
04:07.550 --> 04:08.900
through up to 15.

70
04:09.410 --> 04:12.170
That represents 16 unique values, right?

71
04:12.590 --> 04:17.930
And those last six digits, these are repeated digits.

72
04:18.110 --> 04:19.100
It's just another one.

73
04:19.100 --> 04:24.080
It's just another two, three, four and a five with an extra 1 or 0 placed somewhere.

74
04:24.110 --> 04:31.010
We've used all those digits before in the first ten digits, and that's why this is known as base ten.

75
04:31.040 --> 04:34.490
We don't ever use more than ten unique digits.

76
04:34.640 --> 04:35.630
What about Hex?

77
04:37.340 --> 04:42.800
Hex, as we just said, is base 16 and it uses the characters A through to F as well.

78
04:44.080 --> 04:47.800
But you'll notice now that these are not repeated digits, are they?

79
04:47.830 --> 04:50.440
They are six brand new digits.

80
04:50.800 --> 04:54.520
And this is why Hex is known as base 16.

81
04:55.030 --> 04:55.540
Okay, cool.

82
04:55.540 --> 04:56.230
That makes sense.

83
04:56.230 --> 04:58.060
But how do we count in Hex?

84
04:58.660 --> 05:02.830
Well, counting in hex is very similar to how we count in decimal.

85
05:02.980 --> 05:09.700
Once a digit becomes greater than F, remember, that's the last character in hex,

86
05:09.820 --> 05:15.060
you start at zero again and increment the digit to the left by one ... heh?

87
05:15.340 --> 05:16.090
(sound: well, this is awkward)

88
05:16.090 --> 05:17.140
Confused ðŸ˜•?

89
05:17.590 --> 05:18.190
Don't be.

90
05:18.220 --> 05:18.910
Don't be.

91
05:18.920 --> 05:20.050
It really isn't that bad.

92
05:20.350 --> 05:21.250
Let me show you.

93
05:21.280 --> 05:25.240
So here we've got two tables, decimal and hex. With decimal,

94
05:25.240 --> 05:27.250
let's count up to 7.

95
05:28.160 --> 05:29.570
How do we do that in Hex?

96
05:30.910 --> 05:33.670
Well, it's got exactly the same digits, right?

97
05:34.300 --> 05:36.250
So, nothing changes.

98
05:36.250 --> 05:37.900
This is how we count in Hex.

99
05:38.380 --> 05:41.440
Let's now count from 8 to 15.

100
05:41.980 --> 05:44.800
How is that going to work in Hex? Already, 

101
05:44.800 --> 05:46.630
I'm sure you can figure it out.

102
05:46.660 --> 05:50.530
We've got 8 and 9, which is exactly the same as decimal.

103
05:50.740 --> 05:57.220
And then as we just said, we then get A through to F. All is good and well.

104
05:57.220 --> 06:01.090
But now how do we do say 16 for example?

105
06:01.090 --> 06:02.170
How would that work?

106
06:02.970 --> 06:04.290
Well, it's not that difficult.

107
06:04.290 --> 06:07.500
16 in decimals, just the characters or the digits

108
06:07.500 --> 06:08.460
1 and 6. 

109
06:08.460 --> 06:14.910
With Hex, we start all over again, but we increment the left digit by one.

110
06:14.910 --> 06:20.910
So here we actually literally have a 1, and then we start from scratch, which the first digit in hex

111
06:20.910 --> 06:22.050
is 0.

112
06:22.380 --> 06:28.410
So what that means is if we want to represent the number 17, keeping the left digit the same, and we

113
06:28.410 --> 06:30.330
just keep incrementing by one.

114
06:30.600 --> 06:33.600
Pretty straightforward, and we just keep going on and on.

115
06:33.810 --> 06:41.280
"I'm starting to understand it, but how do I know if a certain number I see on a screen is Hex ... or should

116
06:41.280 --> 06:42.390
it be decimal?

117
06:42.390 --> 06:43.470
Like, how do I know what it is?

118
06:43.470 --> 06:47.700
How do I know what characters are represented to me on a screen when I'm looking at it?"

119
06:48.060 --> 06:51.270
That's a very, very good question. And let me pose it in another way.

120
06:51.870 --> 06:53.970
Say we have these characters on the screen.

121
06:54.780 --> 06:56.250
Am I wanting a drink ...

122
06:57.510 --> 07:00.330
or am I am trying to represent the decimal number

123
07:00.330 --> 07:03.990
74007760487749?

124
07:04.380 --> 07:11.520
Well, to avoid confusing situations like this, you'll often see a hexadecimal number prefix.

125
07:11.520 --> 07:18.510
And that prefix is kind of like a clue to us, or to software, that we are talking hex numbers.

126
07:18.840 --> 07:25.830
And what's really confusing is that we don't only have one prefix, different softwares use different

127
07:25.830 --> 07:26.680
prefixes.

128
07:26.710 --> 07:32.040
I know it's so irritating, but let me just give you an example of a few of the most popular ones I

129
07:32.040 --> 07:32.940
could think of.

130
07:33.180 --> 07:39.330
Firstly, and you'll definitely know this one, we've got the hash symbol and this is also just a hex

131
07:39.330 --> 07:42.580
prefix. And these are just color references in HTML.

132
07:42.600 --> 07:46.500
If you've coded any web page, you would have used these a ton.

133
07:46.740 --> 07:47.070
Okay.

134
07:47.070 --> 07:48.270
What about another type?

135
07:48.300 --> 07:56.200
0x. 0x is a common prefix in UNIX and C-based programming languages. And we get a whole bunch more.

136
07:56.220 --> 08:02.530
Literally, we get tons. We get &#D which represents a Unicode character,

137
08:02.560 --> 08:06.050
\x, 0h etc etc etc. 

138
08:06.070 --> 08:07.150
I don't want to get into that

139
08:07.150 --> 08:07.690
now.

140
08:07.840 --> 08:13.900
The most important one that we have to concentrate on now, is one relating to forms, because this course

141
08:13.900 --> 08:15.100
is all about forms.

142
08:15.100 --> 08:19.600
And sometimes when we're dealing with forms you have to deal with URLs.

143
08:20.020 --> 08:21.910
So what is that prefix?

144
08:21.940 --> 08:24.850
Well, that prefix is the percentage sign.

145
08:24.880 --> 08:31.240
The percentage sign is used in URLs to express different characters in Hex.

146
08:31.450 --> 08:32.920
I hope this is starting to make sense.

147
08:32.920 --> 08:36.400
Don't worry if you not quite sure how it looks in the URL.

148
08:36.430 --> 08:41.530
We're going to be looking at examples shortly. But just taking a step back, there are many different

149
08:41.560 --> 08:43.450
numeral systems out there.

150
08:43.870 --> 08:47.110
We know that binary is the language of computers.

151
08:47.470 --> 08:53.980
Binary uses two digits - ones and zeros - to represent unique values.

152
08:54.100 --> 08:56.050
We just looked at another numeral system.

153
08:56.050 --> 08:59.110
We looked at decimal and we looked at hex.

154
08:59.620 --> 09:02.500
And hex is often used in programming.

155
09:02.500 --> 09:04.380
I don't know why, it's just the way it is.

156
09:04.390 --> 09:12.760
And the community of URLs, the web, they decided that URLs should be based in hexadecimal.

157
09:12.760 --> 09:16.990
So if there's nothing else you've learned in this lecture other than this, then that's okay because

158
09:16.990 --> 09:21.400
it is such a good thing to know that URLs are based in hexadecimal.

159
09:21.430 --> 09:27.640
That's why we could replace the %65 with the letter "e", for example, the browser did that

160
09:27.640 --> 09:28.330
automatically.

161
09:28.330 --> 09:30.580
It can speak one in the same language.

162
09:30.700 --> 09:35.020
But anyway, now that I've introduced you to Hex, I think we can move on.

163
09:35.020 --> 09:38.050
We can start getting into more complex topics.