diff --git a/learn/slides.md b/learn/slides.md index 5000b0e..4694d19 100755 --- a/learn/slides.md +++ b/learn/slides.md @@ -22,7 +22,7 @@ The terms character set is used interchangably with character encoding and code ## Latin ## - Also called ISO-8859-1 character set. -- This is an extension of ASCII and covers the Latin alphabet - think english looking alphabets with diacritics. eg: ร€รค +- This is an extension of ASCII and covers the Latin alphabet - ร€,รค... - Number mappings upto 255. ## Windows 1252 ## @@ -30,7 +30,6 @@ The terms character set is used interchangably with character encoding and code - Super set of Latin character set. - Introduced by Microsoft. - ## Unicode ## - Capable of defining a mapping for 1.1 million characters. @@ -40,7 +39,6 @@ The terms character set is used interchangably with character encoding and code - Emojis ๐Ÿ˜ฎ, ๐Ÿค” - Math โˆซx.dx - --- # Common encoding schemes # @@ -56,9 +54,14 @@ The terms character set is used interchangably with character encoding and code - Today, it only accounts for 1.4% of the internet traffic. ``` -~~~enc-check -8 abcd - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 97 โ”‚ 61 โ”‚ a โ”‚ 0 โ”‚ 61 โ”‚ 97 โ”‚ 01100001 โ”‚ +โ”‚ 98 โ”‚ 62 โ”‚ b โ”‚ 1 โ”‚ 62 โ”‚ 98 โ”‚ 01100010 โ”‚ +โ”‚ 99 โ”‚ 63 โ”‚ c โ”‚ 2 โ”‚ 63 โ”‚ 99 โ”‚ 01100011 โ”‚ +โ”‚ 100 โ”‚ 64 โ”‚ d โ”‚ 3 โ”‚ 64 โ”‚ 100 โ”‚ 01100100 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- @@ -87,9 +90,22 @@ The terms character set is used interchangably with character encoding and code ``` -~~~enc-check -8 abเฎเคน๐Ÿค” - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 97 โ”‚ 61 โ”‚ a โ”‚ 0 โ”‚ 61 โ”‚ 97 โ”‚ 01100001 โ”‚ +โ”‚ 98 โ”‚ 62 โ”‚ b โ”‚ 1 โ”‚ 62 โ”‚ 98 โ”‚ 01100010 โ”‚ +โ”‚ 2960 โ”‚ b90 โ”‚ เฎ โ”‚ 2 โ”‚ e0 โ”‚ 224 โ”‚ 11100000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 3 โ”‚ ae โ”‚ 174 โ”‚ 10101110 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 4 โ”‚ 90 โ”‚ 144 โ”‚ 10010000 โ”‚ +โ”‚ 2361 โ”‚ 939 โ”‚ เคน โ”‚ 5 โ”‚ e0 โ”‚ 224 โ”‚ 11100000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 6 โ”‚ a4 โ”‚ 164 โ”‚ 10100100 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 7 โ”‚ b9 โ”‚ 185 โ”‚ 10111001 โ”‚ +โ”‚ 129300 โ”‚ 1f914 โ”‚ ๐Ÿค” โ”‚ 8 โ”‚ f0 โ”‚ 240 โ”‚ 11110000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 9 โ”‚ 9f โ”‚ 159 โ”‚ 10011111 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 10 โ”‚ a4 โ”‚ 164 โ”‚ 10100100 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 11 โ”‚ 94 โ”‚ 148 โ”‚ 10010100 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- @@ -107,10 +123,22 @@ The terms character set is used interchangably with character encoding and code - 2 or 4 bytes to represent a unicode code point. ``` -~~~enc-check -6 abเฎเคน๐Ÿค” - -~~~ - +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 97 โ”‚ 61 โ”‚ a โ”‚ 0 โ”‚ 00 โ”‚ 0 โ”‚ 00000000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 1 โ”‚ 61 โ”‚ 97 โ”‚ 01100001 โ”‚ +โ”‚ 98 โ”‚ 62 โ”‚ b โ”‚ 2 โ”‚ 00 โ”‚ 0 โ”‚ 00000000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 3 โ”‚ 62 โ”‚ 98 โ”‚ 01100010 โ”‚ +โ”‚ 2960 โ”‚ b90 โ”‚ เฎ โ”‚ 4 โ”‚ 0b โ”‚ 11 โ”‚ 00001011 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 5 โ”‚ 90 โ”‚ 144 โ”‚ 10010000 โ”‚ +โ”‚ 2361 โ”‚ 939 โ”‚ เคน โ”‚ 6 โ”‚ 09 โ”‚ 9 โ”‚ 00001001 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 7 โ”‚ 39 โ”‚ 57 โ”‚ 00111001 โ”‚ +โ”‚ 129300 โ”‚ 1f914 โ”‚ ๐Ÿค” โ”‚ 8 โ”‚ d8 โ”‚ 216 โ”‚ 11011000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 9 โ”‚ 3e โ”‚ 62 โ”‚ 00111110 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 10 โ”‚ dd โ”‚ 221 โ”‚ 11011101 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 11 โ”‚ 14 โ”‚ 20 โ”‚ 00010100 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- @@ -127,20 +155,26 @@ The terms character set is used interchangably with character encoding and code - Encode the string in one of the encoding schemes. - If a particular character cannot appear in the url string, or is not ASCII, print the hex representation of the string, prefixed with a `%`. - ``` -~~~enc-check -8 &? - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 38 โ”‚ 26 โ”‚ & โ”‚ 0 โ”‚ 26 โ”‚ 38 โ”‚ 00100110 โ”‚ +โ”‚ 63 โ”‚ 3f โ”‚ ? โ”‚ 1 โ”‚ 3f โ”‚ 63 โ”‚ 00111111 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` - For example, if the url string `p1&/pw?` were to be url-encoded under utf-8 encoding, then it would be `p1%26/pw%3f` - ``` -~~~enc-check -6 &? - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 38 โ”‚ 26 โ”‚ & โ”‚ 0 โ”‚ 00 โ”‚ 0 โ”‚ 00000000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 1 โ”‚ 26 โ”‚ 38 โ”‚ 00100110 โ”‚ +โ”‚ 63 โ”‚ 3f โ”‚ ? โ”‚ 2 โ”‚ 00 โ”‚ 0 โ”‚ 00000000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 3 โ”‚ 3f โ”‚ 63 โ”‚ 00111111 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` - Under utf-16 encoding, it would be `p1%00%26/pw%00%3f` @@ -152,7 +186,6 @@ The terms character set is used interchangably with character encoding and code - Support Unicode code points encoded as utf-8 characters. - URL encode under utf-8. - --- # What is a character? # @@ -160,11 +193,17 @@ The terms character set is used interchangably with character encoding and code - It is a group of unicode code points - also called a grapheme cluster. - Eg: the character 'เฎชเฏ' consists of 2 unicode code points as seen below. - ``` -~~~enc-check -8 เฎชเฏ - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 2986 โ”‚ baa โ”‚ เฎช โ”‚ 0 โ”‚ e0 โ”‚ 224 โ”‚ 11100000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 1 โ”‚ ae โ”‚ 174 โ”‚ 10101110 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 2 โ”‚ aa โ”‚ 170 โ”‚ 10101010 โ”‚ +โ”‚ 3021 โ”‚ bcd โ”‚ เฏ | 3 โ”‚ e0 โ”‚ 224 โ”‚ 11100000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 4 โ”‚ af โ”‚ 175 โ”‚ 10101111 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 5 โ”‚ 8d โ”‚ 141 โ”‚ 10001101 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` - Number of characters in a string is often different from `string.Length`. @@ -174,9 +213,14 @@ The terms character set is used interchangably with character encoding and code ``` -~~~enc-check -6 ๐Ÿค” - -~~~ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ U+dec โ”‚ U+hex โ”‚ character โ”‚ byte โ”‚ hex โ”‚ dec โ”‚ bin โ”‚ +โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +โ”‚ 129300 โ”‚ 1f914 โ”‚ ๐Ÿค” โ”‚ 0 โ”‚ d8 โ”‚ 216 โ”‚ 11011000 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 1 โ”‚ 3e โ”‚ 62 โ”‚ 00111110 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 2 โ”‚ dd โ”‚ 221 โ”‚ 11011101 โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ 3 โ”‚ 14 โ”‚ 20 โ”‚ 00010100 โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` - Be careful about advertising character length limitations.