Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Wikipedia article on UTF-8 provides a table that shows how non-ASCII characters are <a href="http://en.wikipedia.org/wiki/UTF-8#Design" rel="nofollow">encoded</a>. That table illustrates the following simple rules for UTF-8:</p> <ul> <li><p>If the highest bit of a byte is 0, then the byte denotes an ASCII character.</p></li> <li><p>If the two highest bits of a byte are 11, then this is the start of a multi-byte character, and the number of consecutive 1 bits starting from the highest order bit indicates the total number of bytes in the multi-byte character. Thus, a byte whose bit representation is 110xxxxx is the start of a 2-byte character, 1110xxxx is the start of a 3-byte character, and 11110xxx is the start of a 4-byte character. (You can ignore the hypothetical 5-byte and 6-byte characters because Unicode is limited to being a 21-bit character set rather than a 32-bit character set.)</p></li> <li><p>If the two highest bits of a byte are 10, then this byte is part of a multi-byte character (but <em>not</em> the first byte of that character).</p></li> </ul> <p>That information should be enough for you to write your own utility functions that are like <code>string.length</code> and <code>string.substring()</code> but work in terms of characters instead of bytes.</p> <p><strong>Update:</strong> The question did not specify the programming language being used, and I was not aware that "Template Toolkit" implied the use of Perl. Once I realised that, I did a Google search and discovered that your problem is likely to be due to the need to add a <code>use utf8</code> directive to your source code. You can find a discussion about this <a href="http://perldoc.perl.org/utf8.html" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload