[gjs/locale-agnostic-camel-properties: 1/5] jsapi-util-strings: Ignore locale to compute the upper case of a char




commit 2dd4af317c584991e73fb18c023078576f37e065
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/jsapi-util-string.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
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]