-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
The following code:
So how does UTF-8 actually work? Use the following process to do what the interactive is doing and convert characters to UTF-8 yourself.
1. Lookup the Unicode number of your character.
2. Convert the Unicode number to a binary number, using as **few** bits as necessary.
Look back to the section on binary numbers if you cannot remember how to convert a number to binary.
3. Count how many bits are in the binary number, and choose the correct pattern to use, based on how many bits there were.
Step 4 will explain how to use the pattern.
```
7 or fewer bits: 0xxxxxxx
11 or fewer bits: 110xxxxx 10xxxxxx
16 or fewer bits: 1110xxxx 10xxxxxx 10xxxxxx
21 or fewer bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
```
4. Replace the x's in the pattern with the bits of the binary number you converted in 2.
If there are more x's than bits, replace extra left-most x's with 0's.Should result in:
<ol>
<li>
<p>Lookup the Unicode number of your character.</p>
</li>
<li>
<p>Convert the Unicode number to a binary number, using as <strong>few</strong> bits as necessary.
Look back to the section on binary numbers if you cannot remember how to convert a number to binary.</p>
</li>
<li>
<p>Count how many bits are in the binary number, and choose the correct pattern to use, based on how many bits there were.
Step 4 will explain how to use the pattern.</p>
<pre><code>7 or fewer bits: 0xxxxxxx
11 or fewer bits: 110xxxxx 10xxxxxx
16 or fewer bits: 1110xxxx 10xxxxxx 10xxxxxx
21 or fewer bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx</code></pre>
</li>
<li>
<p>Replace the x's in the pattern with the bits of the binary number you converted in 2.
If there are more x's than bits, replace extra left-most x's with 0's.</p>
</li>
</ol>however instead it renders as:
<ol>
<li>
<p>Lookup the Unicode number of your character.</p>
</li>
<li>
<p>Convert the Unicode number to a binary number, using as <strong>few</strong> bits as necessary.
Look back to the section on binary numbers if you cannot remember how to convert a number to binary.</p>
</li>
<li>
<p>Count how many bits are in the binary number, and choose the correct pattern to use, based on how many bits there were.
Step 4 will explain how to use the pattern.</p>
<p><code>7 or fewer bits: 0xxxxxxx
11 or fewer bits: 110xxxxx 10xxxxxx
16 or fewer bits: 1110xxxx 10xxxxxx 10xxxxxx
21 or fewer bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx</code></p>
</li>
<li>
<p>Replace the x's in the pattern with the bits of the binary number you converted in 2.
If there are more x's than bits, replace extra left-most x's with 0's.</p>
</li>
</ol>Notice the pre block is shown as a p block. This occurs when indented for a list, but may also happen in other circumstances.
Reactions are currently unavailable