Count all first-bytes (the ones that don’t match 10xxxxxx).
int len = 0;
while (*s) len += (*s++ & 0xc0) != 0x80;
More Related Contents:
- Insertion sort stops working after million input
- How to find out how many bits are set (equal 1) in the product of two integers [closed]
- C++ – Find numbers between first and last negative numbers in Array
- Program stopped working, when tried to run
- C++ throwing exception in recursive algorithm
- How to use Quick Sort to sort an array of strings
- How to get the maximum number after erasing n digits from the number [closed]
- Image Processing: Algorithm Improvement for ‘Coca-Cola Can’ Recognition
- Rotating a point about another point (2D)
- Create Random Number Sequence with No Repeats
- Fast ceiling of an integer division in C / C++
- Emulate “double” using 2 “float”s
- Algorithm for finding the smallest power of two that’s greater or equal to a given value [duplicate]
- How can I find the actual path found by BFS?
- Need for predictable random generator
- Splitting a string by a character
- How can I sort a std::map first by value, then by key?
- Iterative DFS vs Recursive DFS and different elements order
- what is the difference between set and unordered_set in C++?
- Similar String algorithm
- Calculating the Amount of Combinations
- Searching in a sorted and rotated array
- Better shading on BW display while rendering filled surfaces
- How can I sort an STL map by value?
- Algorithm to add or subtract days from a date?
- Creating N nested for-loops
- What’s time complexity of this algorithm for finding all combinations?
- Counting number of bits: How does this line work ? n=n&(n-1); [duplicate]
- Good C++ solutions to the “Bring all the zeros to the back of the array” interview challenge
- Finding square root without using sqrt function?