aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-10-25 09:39:31 +0200
committerMartin Ridgers <[email protected]>2021-10-25 09:48:30 +0200
commitc80bc1e4b2ea10c2e871091f996d19a18218f231 (patch)
treef3487b5588c30167ac8278c6079bb8b334f669f7 /zencore/include
parentMerged main (diff)
downloadzen-c80bc1e4b2ea10c2e871091f996d19a18218f231.tar.xz
zen-c80bc1e4b2ea10c2e871091f996d19a18218f231.zip
Cross-platform string comparison helper plus tests
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/string.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h
index 23193501c..7af27ca20 100644
--- a/zencore/include/zencore/string.h
+++ b/zencore/include/zencore/string.h
@@ -696,6 +696,19 @@ ForEachStrTok(const std::string_view& Str, char Delim, Fn&& Func)
//////////////////////////////////////////////////////////////////////////
+inline int32_t
+StrCaseCompare(const char* Lhs, const char* Rhs, int64_t Length=-1)
+{
+ // A helper for cross-platform case-insensitive string comparison.
+#if ZEN_PLATFORM_WINDOWS
+ return (Length < 0) ? _stricmp(Lhs, Rhs) : _strnicmp(Lhs, Rhs, size_t(Length));
+#else
+ return (Length < 0) ? strcasecmp(Lhs, Rhs) : strncasecmp(Lhs, Rhs, size_t(Length));
+#endif
+}
+
+//////////////////////////////////////////////////////////////////////////
+
/**
* ASCII character bitset useful for fast and readable parsing
*