Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarshan Sen <raisinten@gmail.com>2021-06-12 17:12:04 +0300
committerJames M Snell <jasnell@gmail.com>2021-06-14 18:19:51 +0300
commit940f2c2b4750d0647ffabd9cfe1c4bba09e639b6 (patch)
tree3e4953e120a2f8d694414c29bd1f7615d9fda544 /src/util-inl.h
parent68229a9f08ea900979e38df0d6c2612e2197cfe1 (diff)
src: refactor to use locale functions
This makes the code more readable. Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/39014 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r--src/util-inl.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util-inl.h b/src/util-inl.h
index 00a9f836e46..517da707170 100644
--- a/src/util-inl.h
+++ b/src/util-inl.h
@@ -26,6 +26,7 @@
#include <cmath>
#include <cstring>
+#include <locale>
#include "util.h"
// These are defined by <sys/byteorder.h> or <netinet/in.h> on some systems.
@@ -274,7 +275,7 @@ void SwapBytes64(char* data, size_t nbytes) {
}
char ToLower(char c) {
- return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
+ return std::tolower(c, std::locale::classic());
}
std::string ToLower(const std::string& in) {
@@ -285,7 +286,7 @@ std::string ToLower(const std::string& in) {
}
char ToUpper(char c) {
- return c >= 'a' && c <= 'z' ? (c - 'a') + 'A' : c;
+ return std::toupper(c, std::locale::classic());
}
std::string ToUpper(const std::string& in) {