Created
April 30, 2020 23:41
-
-
Save lemire/8ffbec17d65bb5723979bb066b58a771 to your computer and use it in GitHub Desktop.
is_utf8_continuing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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