Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 902bb85

Browse filesBrowse files
RaisinTendanielleadams
authored andcommitted
src: refactor to use locale functions
This makes the code more readable. Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #39014 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 858f66e commit 902bb85
Copy full SHA for 902bb85

File tree

Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed
Open diff view settings
Collapse file

‎src/inspector/node_string.cc‎

Copy file name to clipboardExpand all lines: src/inspector/node_string.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ String StringViewToUtf8(v8_inspector::StringView view) {
7171

7272
String fromDouble(double d) {
7373
std::ostringstream stream;
74-
stream.imbue(std::locale("C")); // Ignore locale
74+
stream.imbue(std::locale::classic()); // Ignore current locale
7575
stream << d;
7676
return stream.str();
7777
}
7878

7979
double toDouble(const char* buffer, size_t length, bool* ok) {
8080
std::istringstream stream(std::string(buffer, length));
81-
stream.imbue(std::locale("C")); // Ignore locale
81+
stream.imbue(std::locale::classic()); // Ignore current locale
8282
double d;
8383
stream >> d;
8484
*ok = !stream.fail();
Collapse file

‎src/tracing/traced_value.cc‎

Copy file name to clipboardExpand all lines: src/tracing/traced_value.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ std::string DoubleToCString(double v) {
9494
default:
9595
// This is a far less sophisticated version than the one used inside v8.
9696
std::ostringstream stream;
97-
stream.imbue(std::locale("C")); // Ignore locale
97+
stream.imbue(std::locale::classic()); // Ignore current locale
9898
stream << v;
9999
return stream.str();
100100
}
Collapse file

‎src/util-inl.h‎

Copy file name to clipboardExpand all lines: src/util-inl.h
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <cmath>
2828
#include <cstring>
29+
#include <locale>
2930
#include "util.h"
3031

3132
// 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) {
274275
}
275276

276277
char ToLower(char c) {
277-
return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c;
278+
return std::tolower(c, std::locale::classic());
278279
}
279280

280281
std::string ToLower(const std::string& in) {
@@ -285,7 +286,7 @@ std::string ToLower(const std::string& in) {
285286
}
286287

287288
char ToUpper(char c) {
288-
return c >= 'a' && c <= 'z' ? (c - 'a') + 'A' : c;
289+
return std::toupper(c, std::locale::classic());
289290
}
290291

291292
std::string ToUpper(const std::string& in) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.