[libc-commits] [libc] [libc] Support %lc in printf (PR #169983)

Shubh Pachchigar via libc-commits libc-commits at lists.llvm.org
Fri Dec 26 09:58:16 PST 2025


================
@@ -3487,3 +3492,61 @@ TEST(LlvmLibcSPrintfTest, IndexModeParsing) {
                    "why would u do this, this is such   a pain. %");
 }
 #endif // LIBC_COPT_PRINTF_DISABLE_INDEX_MODE
+
+#ifndef LIBC_COPT_PRINTF_DISABLE_WIDE
+TEST(LlvmLibcSprintfTest, WideCharConversion) {
+  char buff[16];
+  int written;
----------------
shubhe25p wrote:

Would that mean I need to call sprintf twice?

```
  EXPECT_EQ(LIBC_NAMESPACE::sprintf(buff, "%lc", L'€'), 3);
  ASSERT_STREQ_LEN(LIBC_NAMESPACE::sprintf(buff, "%lc", L'€'), buff, "€");
```

Is it fine?

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


More information about the libc-commits mailing list