[libc-commits] [libc] [libc] Implemented CharacterConverter push/pop for utf32->utf8 conversions (PR #143971)

Brooks Moses via libc-commits libc-commits at lists.llvm.org
Fri Jun 13 16:27:04 PDT 2025


================
@@ -22,13 +24,61 @@ bool CharacterConverter::isComplete() {
   return state->bytes_processed == state->total_bytes;
 }
 
-int CharacterConverter::push(char8_t utf8_byte) {}
+int CharacterConverter::push(char32_t utf32) {
+  state->partial = utf32;
+  state->bytes_processed = 0;
+  state->total_bytes = 0;
 
-int CharacterConverter::push(char32_t utf32) {}
+  // determine number of utf-8 bytes needed to represent this utf32 value
+  constexpr char32_t ranges[] = {0x7f, 0x7ff, 0xffff, 0x10ffff};
----------------
brooksmoses wrote:

Some of your constants are lower-case and some upper-case.  Be consistent?

Also "ranges" is a bit generic for a name.

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


More information about the libc-commits mailing list