MCPcopy Create free account
hub / github.com/apache/singa / CaseInsensitiveWideCStringEquals

Method CaseInsensitiveWideCStringEquals

test/gtest/gtest-all.cc:3086–3106  ·  view source on GitHub ↗

Compares two wide C strings, ignoring case. Returns true iff they have the same content. Unlike wcscasecmp(), this function can handle NULL argument(s). A NULL C string is considered different to any non-NULL wide C string, including the empty string. NB: The implementations on different platforms slightly differ. On windows, this method uses _wcsicmp which compares according to LC_CTYPE environ

Source from the content-addressed store, hash-verified

3084 // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
3085 // current locale.
3086bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
3087 const wchar_t* rhs) {
3088 if (lhs == NULL) return rhs == NULL;
3089
3090 if (rhs == NULL) return false;
3091
3092#if GTEST_OS_WINDOWS
3093 return _wcsicmp(lhs, rhs) == 0;
3094#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
3095 return wcscasecmp(lhs, rhs) == 0;
3096#else
3097 // Android, Mac OS X and Cygwin don't define wcscasecmp.
3098 // Other unknown OSes may not define it either.
3099 wint_t left, right;
3100 do {
3101 left = towlower(*lhs++);
3102 right = towlower(*rhs++);
3103 } while (left && left == right);
3104 return left == right;
3105#endif // OS selector
3106}
3107
3108// Returns true iff str ends with the given suffix, ignoring case.
3109// Any string is considered to end with an empty suffix.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected