ref: 7d78ccaab7bb7be44b8e326f7a7b807f187761f3
parent: 3b5c4d0f2ce435345a50a2fd240df753bd9f7104
author: Brian Kernighan <fakeuser@fake.com>
date: Sun Oct 2 09:34:55 EDT 2022
added test cases %-w.ps examples of utf8 in format()
--- a/run.c
+++ b/run.c
@@ -1187,7 +1187,6 @@
}
}
//printf("}\n");- *p++ = 0;
*p = 0;
break;
}
--- a/testdir/T.utf
+++ b/testdir/T.utf
@@ -162,4 +162,33 @@
现在是时候了 现 在
😀🖕 😀 🖕
+# printf(%N.Ns) for utf8 strings
+try printfs1 {printf("[%5.2s][%-5.2s]\n"), $1, $1}+abcd [ ab][ab ]
+现在abc [ 现在][现在 ]
+现ωabc [ 现ω][现ω ]
+ωabc [ ωa][ωa ]
+Сейчас [ Се][Се ]
+Сейxyz [ Се][Се ]
+😀 [ 😀][😀 ]
+
+# printf(%N.Ns) for utf8 strings
+try printfs2 {printf("[%5s][%-5s]\n"), $1, $1}+abcd [ abcd][abcd ]
+现在ab [ 现在ab][现在ab ]
+a现在ab [a现在ab][a现在ab]
+a现在abc [a现在abc][a现在abc]
+现ωab [ 现ωab][现ωab ]
+ωabc [ ωabc][ωabc ]
+Сейчас [Сейчас][Сейчас]
+😀 [ 😀][😀 ]
+
+# printf(%N.Ns) for utf8 strings
+try printfs3 {printf("[%.2s][%-.2s]\n"), $1, $1}+abcd [ab][ab]
+现在abc [现在][现在]
+现ωabc [现ω][现ω]
+ω [ω][ω]
+😀 [😀][😀]
+
!!!!
--
⑨