[libc-commits] [libc] [llvm] [libc] Change ctype to be encoding independent (PR #110574)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Dec 2 11:27:56 PST 2024


================
@@ -138,9 +135,11 @@ LIBC_INLINE int convert_float_hex_exp(Writer *writer,
   size_t mant_cur = mant_len;
   size_t first_non_zero = 1;
   for (; mant_cur > 0; --mant_cur, mantissa >>= 4) {
-    char mant_mod_16 = static_cast<char>(mantissa) & 15;
-    char new_digit = static_cast<char>(
-        (mant_mod_16 > 9) ? (mant_mod_16 - 10 + a) : (mant_mod_16 + '0'));
+    char mant_mod_16 = static_cast<char>(mantissa % 16);
+    char new_digit = static_cast<char>(internal::int_to_b36_char(mant_mod_16));
+    if (internal::isupper(to_conv.conv_name)) {
+      new_digit = static_cast<char>(internal::toupper(new_digit));
+    }
----------------
nickdesaulniers wrote:

```suggestion
    if (internal::isupper(to_conv.conv_name))
      new_digit = static_cast<char>(internal::toupper(new_digit));
```

https://github.com/llvm/llvm-project/pull/110574


More information about the libc-commits mailing list