Skip to content

Instantly share code, notes, and snippets.

@lemire
Created April 30, 2020 23:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemire/8ffbec17d65bb5723979bb066b58a771 to your computer and use it in GitHub Desktop.
Save lemire/8ffbec17d65bb5723979bb066b58a771 to your computer and use it in GitHub Desktop.
is_utf8_continuing
// returns true if the provided byte value is a
// "continuing" UTF-8 value, that is, if it starts with
// 0b10...
static inline bool is_utf8_continuing(char c) {
// in 2 complement's notation, values start at 0b10000 (-128)... and
// go up to 0b11111 (-1)... so we want all values from -128 to -65 (which is 0b10111111)
return ((signed char)c) <= -65;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment