wrong compare of empty strings
Lightweight C++11 library for embedding Unicode
Brought to you by:
ijake1111
Hello i have encountered problem with comparing empty strings (well one is null and one empty with only char '\0')
utf8_string str1 = "";
utf8_string str2;
std::cout << (str1 == str2) << std::endl; // prints out "0"
return 0;
~~~
In my codebase i resolved it with following change:
inline bool utf8_string::equals( const char str ) const
{
const char it1 = this->buffer;
if (!it1) {
return (!str || !*str);
}
else if (!str) {
return (!it1 || !*it1);
}
while( *it1 && *str ){
if( *it1 != *str )
return false;
it1++;
str++;
}
return *it1 == *str;
}
~~~
Also considering your lack of time, could you move the project to github so other users can contribute?
well sorry for the formating ...
Fixed on Github :)