From f37875c6c4e42055735f1cda9fdbcb7ab11b80bc Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Fri, 13 Dec 2024 15:14:15 -0500 Subject: Add c0 and c1 control width options This allows a build of DisplayWidth to give characters in those classes a width, for cases where they'll be printed with a substitute in the final display. It also raises the size of possible characters from an i3 to an i4, to accommodate printing C1s as e.g. <80> or \u{80}. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index bad64fc..c4227a2 100644 --- a/README.md +++ b/README.md @@ -441,7 +441,7 @@ test "Display width" { } ``` -This has a build option, `"cjk"`, which will consider [ambiguous characters](https://www.unicode.org/reports/tr11/tr11-6.html) as double-width. +This module has build options. The first is `cjk`, which will consider [ambiguous characters](https://www.unicode.org/reports/tr11/tr11-6.html) as double-width. To choose this option, add it to the dependency like so: @@ -451,6 +451,8 @@ const zg = b.dependency("zg", .{ }); ``` +The other options are `c0_width` and `c1_width`. The standard behavior is to treat C0 and C1 control codes as zero-width, except for delete and backspace, which are -1 (the logic ensures that a `strWidth` is always at least 0). If printing control codes with replacement characters, it's necessary to assign these a width, hence the options. When provided these values must fit in an `i4`, this allows for C1s to be printed as `\u{80}` if desired. + ## Scripts Unicode categorizes code points by the Script in which they belong. A Script -- cgit v1.2.3