diff options
author | 251 <13120787+251Labs@users.noreply.github.com> | 2018-08-28 18:42:27 +0200 |
---|---|---|
committer | 251 <13120787+251Labs@users.noreply.github.com> | 2018-08-28 18:42:27 +0200 |
commit | 7a208d9fade56e2347891daff2f6b903923c9d50 (patch) | |
tree | 575ae31e45b1069110bd344f0eb27d8ee8ef6ddb /src/utilstrencodings.cpp | |
parent | e2ba043b8d852d3f465bc293d6e494c8c6f75dfd (diff) | |
download | bitcoin-7a208d9fade56e2347891daff2f6b903923c9d50.tar.xz |
Implements custom tolower and toupper functions.
This commit implements custom equivalents for the C and C++ `tolower` and `toupper` Standard Library functions.
In addition it implements a utility function to capitalize the first letter of a string.
Diffstat (limited to 'src/utilstrencodings.cpp')
-rw-r--r-- | src/utilstrencodings.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index e66e2c238c..2326383586 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -7,6 +7,7 @@ #include <tinyformat.h> +#include <algorithm> #include <cstdlib> #include <cstring> #include <errno.h> @@ -584,3 +585,15 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa } return true; } + +void Downcase(std::string& str) +{ + std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){return ToLower(c);}); +} + +std::string Capitalize(std::string str) +{ + if (str.empty()) return str; + str[0] = ToUpper(str.front()); + return str; +} |