[gjs/gnome-42] jsapi-util-strings: Ignore locale to compute the upper case of a char
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-42] jsapi-util-strings: Ignore locale to compute the upper case of a char
- Date: Tue, 5 Jul 2022 03:30:50 +0000 (UTC)
commit 22fcbb67364f6b26a3379a23652c366432a198ff
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Thu Apr 28 19:53:59 2022 +0200
jsapi-util-strings: Ignore locale to compute the upper case of a char
We used to compute camel-case name of properties using toupper(),
however this is locale-dependent, while in this case we want to be sure
that we're only using ASCII values.
This is particularly problematic in Turkish (and maybe other locales)
because there 'i'.toLocaleUpperCase() is 'Ä°', that is definitely not an
ASCII char, causing problems to with our generated properties.
See: https://github.com/micheleg/dash-to-dock/issues/1687
gjs/gjs_pch.hh | 1 -
gjs/jsapi-util-string.cpp | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/gjs/gjs_pch.hh b/gjs/gjs_pch.hh
index 46bea8a9b..6f1b0b4fb 100644
--- a/gjs/gjs_pch.hh
+++ b/gjs/gjs_pch.hh
@@ -28,7 +28,6 @@
#include <vector>
#include <assert.h>
-#include <ctype.h>
#include <errno.h>
#include <ffi.h>
#include <gio/gio.h>
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index c78069a83..a39a0c055 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -4,7 +4,6 @@
#include <config.h>
-#include <ctype.h> // for toupper
#include <stdint.h>
#include <string.h> // for size_t, strlen
#include <sys/types.h> // for ssize_t
@@ -59,7 +58,7 @@ GjsAutoChar gjs_hyphen_to_camel(const char* str) {
if (*input_iter == '-') {
uppercase_next = true;
} else if (uppercase_next) {
- *output_iter++ = toupper(*input_iter);
+ *output_iter++ = g_ascii_toupper(*input_iter);
uppercase_next = false;
} else {
*output_iter++ = *input_iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]