WEBVTT 00:01.960 --> 00:03.730 Welcome this lecture. 00:03.760 --> 00:06.370 You're going to learn how to get the length of a string. 00:07.490 --> 00:08.150 Let's start. 00:09.630 --> 00:14.820 Now, let's take a look at this example, let's just declare a string variable with an initial value 00:14.820 --> 00:17.400 of call down less time Prenzler. 00:18.530 --> 00:26.020 And here, let's find out the length of the value inside the names variable by typing Lannes name is 00:26.030 --> 00:26.820 just Cipha. 00:27.020 --> 00:32.510 Lan is a built in function so you don't have to import a package to use it. 00:33.230 --> 00:34.790 OK, now let's run this program. 00:37.140 --> 00:43.440 As you can see, it brings four so you can use the land function to find out how many characters in 00:43.440 --> 00:44.140 a string value. 00:45.030 --> 00:50.060 However, this is only true for a string value, which only contains English characters. 00:50.250 --> 00:56.530 Actually, the land function finds out how many bytes string value it actually doesn't find. 00:56.550 --> 00:58.170 How many characters in a string? 00:59.440 --> 01:04.530 Let's change the name variables value to my name, which contains non English letters as well. 01:04.870 --> 01:07.110 I'll return back to this topic afterwards. 01:07.570 --> 01:13.240 But as a teaser, let me tell you that strangelet clothes are made up of Unicode code points. 01:13.240 --> 01:21.130 Call to rooms and rooms are made up of bytes so each character can be one byte or up to four bytes. 01:22.280 --> 01:24.960 I'm going to talk about that later, OK? 01:25.160 --> 01:26.650 Let's return to my name now. 01:27.380 --> 01:29.900 As you can see, there are five letters in my name. 01:32.610 --> 01:39.690 The first letter is E, which is two bites and the next three letters since they are English letters. 01:39.720 --> 01:47.190 Each letter is one bite and the last letter chair is two bites, just like the first non English letter. 01:48.190 --> 01:50.900 So non English characters need more bites, right? 01:51.520 --> 01:56.320 Not these last, but other non English characters can take up to four bites. 01:56.320 --> 01:59.770 Each can guess how many bites there are in my name. 02:01.560 --> 02:03.160 The we do now think about it. 02:08.060 --> 02:09.380 OK, I'm running it now. 02:10.570 --> 02:16.980 As you can see, my name takes seven bites in total, so it's clear that the lamb function just returns, 02:16.990 --> 02:20.770 the bites doesn't return the actual number of characters. 02:21.100 --> 02:24.970 So you cannot trust it for calculating the length of a string value. 02:24.980 --> 02:25.360 Right. 02:26.080 --> 02:28.210 I feel that now you're thinking. 02:28.240 --> 02:31.490 So how can I find out how many characters in a shrink? 02:32.300 --> 02:33.040 Let me show you. 02:34.530 --> 02:39.720 OK, this is the same program I'm going to import a new package called UTF eight. 02:40.980 --> 02:47.700 This package helps you to work with UTF eight encoded string values, and this import statement is a 02:47.700 --> 02:51.220 multiple import statement to save space. 02:51.240 --> 02:55.720 I typed it in one line by using a semicolon between the package names. 02:56.400 --> 02:57.740 There is one more thing here. 02:57.900 --> 03:04.860 The UTF eight package leaves inside the Unicode Packages directory, but UTF eight isn't a package of 03:04.860 --> 03:05.870 the Unicode package. 03:06.210 --> 03:07.500 There is no such packaging. 03:07.500 --> 03:11.310 Engo UTF package is just under the Unicode folder. 03:11.820 --> 03:14.540 This is only for the package organization purposes. 03:14.700 --> 03:18.270 So the real name of the package is only UTF eight. 03:19.790 --> 03:26.420 OK, now I'm going to use a function from the UTF eight package room count in string function takes 03:26.420 --> 03:32.150 on UTF eight encoded string value and returns an integer value it returns. 03:32.150 --> 03:35.770 How many actual characters inside the past think value? 03:36.230 --> 03:42.630 Put simply, a room can represent almost any letters, including English and non English letters. 03:42.800 --> 03:45.080 I'll talk about the rules in detail later. 03:45.800 --> 03:49.370 As you just saw, the land function only counts bytes. 03:49.880 --> 03:54.420 However, this function counts the actual characters inside a string. 03:54.980 --> 03:59.260 So when I say character, I actually mean code points or simple rules. 04:00.080 --> 04:01.210 OK, let's run it now. 04:02.860 --> 04:08.710 As you can see, my name contains five characters, and the room count in string function correctly 04:08.710 --> 04:09.330 returns it. 04:09.910 --> 04:16.000 So when you work with non English characters and first string value is UTF eight encoded, you should 04:16.000 --> 04:17.350 always use this function. 04:17.710 --> 04:24.060 As I said before, all in literal single are UTF eight encoded, but string values are not. 04:24.520 --> 04:25.500 There is a difference. 04:25.960 --> 04:27.970 You'll learn more about this afterwards. 04:29.080 --> 04:30.080 All right, congrats. 04:30.290 --> 04:33.520 Now you learned how to properly find the length of a shrink. 04:34.000 --> 04:34.530 All right. 04:34.540 --> 04:35.800 See you in the next lecture.