[libc-commits] [libc] [libc] Add UTF-16 support in CharacterConverter [1/6] (PR #230434)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Oct 13 15:58:48 PDT 2026


================
@@ -127,6 +194,57 @@ LIBC_INLINE int CharacterConverter::push(char8_t utf8_byte) {
   return EILSEQ;
 }
 
+LIBC_INLINE int CharacterConverter::push(char16_t utf16) {
+  // Checking for high surrogate if first push
+  if (isEmpty()) {
+    bool is_surrogate = (utf16 & 0xF800) == 0xD800;
+    if (is_surrogate) {
+      bool is_high_surrogate = (utf16 & 0x400) == 0;
----------------
michaelrj-google wrote:

if a variable isn't expected to change then adding `const` to it is a helpful hint to the compiler of that fact.

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


More information about the libc-commits mailing list