+
+ {
+ uint8_t c[6];
+ size_t uc_size;
+ uc_size = u8_uctomb_aux (c, uc, 6);
+
+ if (n < uc_size)
+ return NULL;
+
+ /* For multibyte character matching we use a Boyer-Moore like
+ algorithm that searches for the last byte, skipping multi-byte
+ jumps, and matches back from there.
+
+ Instead of using a table as is usual for Boyer-Moore, we compare
+ the candidate last byte s[UC_SIZE-1] with each of the possible
+ bytes in the UTF-8 representation of UC. If the final byte does
+ not match, we will perform up to UC_SIZE comparisons per memory
+ load---but each comparison lets us skip one byte in the input!
+
+ If the final byte matches, the "real" Boyer-Moore algorithm
+ is approximated. Instead, u8_chr just looks for other cN that
+ are equal to the final byte and uses those to try realigning to
+ another possible match. For example, when searching for 0xF0
+ 0xAA 0xBB 0xAA it will always skip forward by two bytes, even if
+ the character in the string was for example 0xF1 0xAA 0xBB 0xAA.
+ The advantage of this scheme is that the skip count after a failed
+ match can be computed outside the loop, and that it keeps the
+ complexity low for a pretty rare case. In particular, since c[0]
+ is never between 0x80 and 0xBF, c[0] is never equal to c[UC_SIZE-1]
+ and this is optimal for two-byte UTF-8 characters. */
+ switch (uc_size)