3 #define PRISM_MEMCHR_TRAILING_BYTE_MINIMUM 0x40
12 if (encoding_changed && encoding->
multibyte && character >= PRISM_MEMCHR_TRAILING_BYTE_MINIMUM) {
13 const uint8_t *source = (
const uint8_t *) memory;
16 while (index < number) {
17 if (source[index] == character) {
18 return (
void *) (source + index);
21 size_t width = encoding->
char_width(source + index, (ptrdiff_t) (number - index));
31 return memchr(memory, character, number);
35 #undef PRISM_MEMCHR_TRAILING_BYTE_MINIMUM
A custom memchr implementation.
void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding)
We need to roll our own memchr to handle cases where the encoding changes and we need to search for a...
This struct defines the functions necessary to implement the encoding interface so we can determine h...
size_t(* char_width)(const uint8_t *b, ptrdiff_t n)
Return the number of bytes that the next character takes if it is valid in the encoding.
bool multibyte
Return true if the encoding is a multibyte encoding.