sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.71k stars 122 forks source link

Bug preventing needle from being found. #37

Closed ghost closed 7 years ago

ghost commented 7 years ago

The utf8casestr function had a bug that prevented needle from being found in haystack when the needle existed at the end of haystack. This commit fixes that.

For example, the string "Hi\0" (null-terminator for emphasis) as the haystack and "HI\0" as the needle where the needle is stored in dynamic memory and haystack may or may not be. utf8casestr will continue going as long as they are both equal, even if they continue being equal past their actual lengths. However, once needle is not equivalent to '\0' after the end of the string, it determines that the needle did not exist in the haystack.

sheredom commented 7 years ago

Good catch thanks! 😄