[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:55 PST 2024


================
@@ -214,9 +215,9 @@ template <typename T, typename Fmt = radix::Dec> class IntegerToString {
     using UNSIGNED_T = make_integral_or_big_int_unsigned_t<T>;
 
     LIBC_INLINE static char digit_char(uint8_t digit) {
-      if (digit < 10)
-        return '0' + static_cast<char>(digit);
-      return (Fmt::IS_UPPERCASE ? 'A' : 'a') + static_cast<char>(digit - 10);
+      const char result = static_cast<char>(internal::int_to_b36_char(digit));
+      return static_cast<char>(Fmt::IS_UPPERCASE ? internal::toupper(result)
----------------
nickdesaulniers wrote:

It looks like there's an extra cast in here, that might not be necessary?
```suggestion
      const int result = internal::int_to_b36_char(digit);
      return static_cast<char>(Fmt::IS_UPPERCASE ? internal::toupper(result)
```

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


More information about the libc-commits mailing list