summaryrefslogtreecommitdiff
path: root/zen/string_tools.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-07-22 16:56:03 +0000
committerB Stack <bgstack15@gmail.com>2020-07-22 16:56:03 +0000
commite5633fb1c0db91f01ab967330b76baf4ecdb0512 (patch)
tree10260e25ae905564f7978b83fc4e316670f987c6 /zen/string_tools.h
parentMerge branch '10.25' into 'master' (diff)
parentadd upstream 11.0 (diff)
downloadFreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.gz
FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.tar.bz2
FreeFileSync-e5633fb1c0db91f01ab967330b76baf4ecdb0512.zip
Merge branch '11.0' into 'master'11.0
add upstream 11.0 See merge request opensource-tracking/FreeFileSync!24
Diffstat (limited to 'zen/string_tools.h')
-rw-r--r--zen/string_tools.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/zen/string_tools.h b/zen/string_tools.h
index eaf1a700..cfdb27bd 100644
--- a/zen/string_tools.h
+++ b/zen/string_tools.h
@@ -26,6 +26,7 @@ template <class Char> bool isWhiteSpace(Char c);
template <class Char> bool isLineBreak (Char c);
template <class Char> bool isDigit (Char c); //not exactly the same as "std::isdigit" -> we consider '0'-'9' only!
template <class Char> bool isHexDigit (Char c);
+template <class Char> bool isAsciiChar (Char c);
template <class Char> bool isAsciiAlpha(Char c);
template <class S > bool isAsciiString(const S& str);
template <class Char> Char asciiToLower(Char c);
@@ -143,6 +144,13 @@ bool isHexDigit(Char c)
template <class Char> inline
+bool isAsciiChar(Char c)
+{
+ return makeUnsigned(c) < 128;
+}
+
+
+template <class Char> inline
bool isAsciiAlpha(Char c)
{
static_assert(std::is_same_v<Char, char> || std::is_same_v<Char, wchar_t>);
@@ -155,7 +163,7 @@ template <class S> inline
bool isAsciiString(const S& str)
{
const auto* const first = strBegin(str);
- return std::all_of(first, first + strLength(str), [](auto c) { return makeUnsigned(c) < 128; });
+ return std::all_of(first, first + strLength(str), [](auto c) { return isAsciiChar(c); });
}
@@ -255,7 +263,7 @@ int compareString(const S& lhs, const T& rhs)
const size_t lhsLen = strLength(lhs);
const size_t rhsLen = strLength(rhs);
- //length check *after* strcmpWithNulls(): we do care about natural ordering: e.g. for "compareString(makeUpperCopy(lhs), makeUpperCopy(rhs))"
+ //length check *after* strcmpWithNulls(): we do care about natural ordering: e.g. for "compareString(getUpperCase(lhs), getUpperCase(rhs))"
if (const int rv = impl::strcmpWithNulls(strBegin(lhs), strBegin(rhs), std::min(lhsLen, rhsLen));
rv != 0)
return rv;
bgstack15