https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9ee8eacb8d60e4e8a55a3908a9b218fde752c258

commit 9ee8eacb8d60e4e8a55a3908a9b218fde752c258
Author:     Thomas Wolff <[email protected]>
AuthorDate: Mon Feb 2 00:00:00 2026 +0000
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Mon Feb 2 18:31:12 2026 +0100

    towupper/towlower: handle Turkic language special casing
    
    For case conversion, Unicode has a standard mapping and a separate
    list of mapping rules for special cases (file SpecialCasing.txt),
    some of which are also language-dependent (as configured via locale).
    However, most of these rules are context-dependent, e.g. Greek capital
    Sigma is lowered to two different small sigmas, depending on the
    position at the end of a word.
    The POSIX API function towupper and tolower cannot consider context
    as they work only on one character at a time. String casing functions
    are unfortunately not available. The only special case conversions
    that apply to a single character are i and I in Turkish and Azerbaijani,
    where i keeps the dot when capitalised (U+0130) and I keeps not having
    a dot when converted small (U+0131).
    The patch handles these special cases, based on locale consideration.
    
    (cherry picked from commit 4356ccd02c9c51a0b0f0babc483567c129ba5393)

Diff:
---
 newlib/libc/ctype/towctrans.c   |  2 +-
 newlib/libc/ctype/towctrans_l.c | 23 +++++++++++++++++++----
 winsup/cygwin/release/3.6.7     |  3 +++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/ctype/towctrans.c b/newlib/libc/ctype/towctrans.c
index 176aa3d9dbdb..2cd34184e006 100644
--- a/newlib/libc/ctype/towctrans.c
+++ b/newlib/libc/ctype/towctrans.c
@@ -81,7 +81,7 @@ _towctrans_r (struct _reent *r,
        wctrans_t w)
 {
   if (w == WCT_TOLOWER || w == WCT_TOUPPER)
-    return towctrans_l (c, w, 0);
+    return towctrans_l (c, w, LC_GLOBAL_LOCALE);
   else
     {
       // skipping this because it was causing trouble (cygwin crash)
diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index b829266a49cd..67aea920b423 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -69,9 +69,21 @@ bisearch (wint_t ucs, const struct caseconv_entry *table, 
int max)
   return 0;
 }
 
+static int
+isturk (struct __locale_t *locale)
+{
+  const char * loc = getlocalename_l (LC_CTYPE, locale);
+  if (!loc)
+    return 0;
+  return 0 == strncmp (loc, "tr", 2) || 0 == strncmp (loc, "az", 2);
+}
+
 static wint_t
-toulower (wint_t c)
+toulower (wint_t c, struct __locale_t *locale)
 {
+  if (c == 'I' && isturk (locale))
+    return 0x131; // LATIN SMALL LETTER DOTLESS I
+
   const struct caseconv_entry * cce =
     bisearch(c, caseconv_table,
              sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
@@ -105,8 +117,11 @@ toulower (wint_t c)
 }
 
 static wint_t
-touupper (wint_t c)
+touupper (wint_t c, struct __locale_t *locale)
 {
+  if (c == 'i' && isturk (locale))
+    return 0x130; // LATIN CAPITAL LETTER I WITH DOT ABOVE
+
   const struct caseconv_entry * cce =
     bisearch(c, caseconv_table,
              sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
@@ -145,9 +160,9 @@ towctrans_l (wint_t c, wctrans_t w, struct __locale_t 
*locale)
   wint_t u = _jp2uc_l (c, locale);
   wint_t res;
   if (w == WCT_TOLOWER)
-    res = toulower (u);
+    res = toulower (u, locale);
   else if (w == WCT_TOUPPER)
-    res = touupper (u);
+    res = touupper (u, locale);
   else
     {
       // skipping the errno setting that was previously involved
diff --git a/winsup/cygwin/release/3.6.7 b/winsup/cygwin/release/3.6.7
index 050f6008084e..5285ba042a44 100644
--- a/winsup/cygwin/release/3.6.7
+++ b/winsup/cygwin/release/3.6.7
@@ -7,3 +7,6 @@ Fixes:
 - Allow changing primary group even when running with cygserver account
   caching.
   Addresses: https://cygwin.com/pipermail/cygwin/2026-January/259250.html
+
+- Correctly handle i->İ, I->ı conversion in turk lnd azerbaijani languages
+  (LC_CTYPE=tr_TR, tr_CY, az_AZ).

Reply via email to