Add UTF8StringNonASCIICount

This commit is contained in:
Henrik Rydgard committed 2013-03-11 21:31:44 +01:00
1 parent e0d107ad20
commit 7f18e1faab
2 files changed
+10 -3

No files matched your search

+8 -3
View File
@@ -394,12 +394,17 @@ int u8_is_locale_utf8(const char *locale)
return 0;
}
bool UTF8StringHasNonASCII(const char *utf8string) {
int UTF8StringNonASCIICount(const char *utf8string) {
UTF8 utf(utf8string);
int count = 0;
while (!utf.end()) {
int c = utf.next();
if (c > 127)
return true;
++count;
}
return false;
return count;
}
bool UTF8StringHasNonASCII(const char *utf8string) {
return UTF8StringNonASCIICount(utf8string) > 0;
}
+2
View File
@@ -35,4 +35,6 @@ private:
int index_;
};
int UTF8StringNonASCIICount(const char *utf8string);
bool UTF8StringHasNonASCII(const char *utf8string);