diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-01-21 16:19:54 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-21 20:31:13 -0700 |
| commit | 2d9c4792ae2cab0ff3b1df54b15913dcbcaef112 (patch) | |
| tree | 409712b979b464dc89d65aed7a019c40fe63af04 /lib/std/fmt.zig | |
| parent | 559bbf1cc669501ff1f1f59d75577691d96450a0 (diff) | |
| download | zig-2d9c4792ae2cab0ff3b1df54b15913dcbcaef112.tar.gz zig-2d9c4792ae2cab0ff3b1df54b15913dcbcaef112.zip | |
std.fmt: clarify the use of "character"
Currently, std.fmt has a misguided, half-assed Unicode implementation
with an ambiguous definition of the word "character". This commit does
almost nothing to mitigate the problem, but it lets me close an open PR.
In the future I will revert 473cb1fd74d6d478bb3d5fda4707ce3f6e6e5bf6 as
well as 279607cae58f7be46335793df6a4a753d0a800aa, and redo the whole
std.fmt API, breaking everyone's code and unfortunately causing nearly
every Zig user to have a bad day. std.fmt will go back to only dealing
in bytes, with zero Unicode awareness whatsoever. I suggest a third
party package provide Unicode functionality as well as a more advanced
text formatting function for when Unicode awareness is needed. I have
always suggested this, and I sincerely apologize for merging pull
requests that compromised my stance on this matter.
Most applications should, instead, strive to make their code independent
of Unicode, dealing strictly in encoded UTF-8 bytes, and never attempt
operations such as: substring manipulation, capitalization, alignment,
word replacement, or column number calculations.
Exceptions to this include web browsers, GUI toolkits, and terminals. If
you're not making one of these, any dependency on Unicode is probably a
bug or worse, a poor design decision.
closes #18536
Diffstat (limited to 'lib/std/fmt.zig')
| -rw-r--r-- | lib/std/fmt.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 6bb7e26da8..a9e1d73c0a 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -40,9 +40,9 @@ pub const FormatOptions = struct { /// - when using a field name, you are required to enclose the field name (an identifier) in square /// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...} /// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below) -/// - *fill* is a single character which is used to pad the formatted text -/// - *alignment* is one of the three characters `<`, `^`, or `>` to make the text left-, center-, or right-aligned, respectively -/// - *width* is the total width of the field in characters +/// - *fill* is a single unicode codepoint which is used to pad the formatted text +/// - *alignment* is one of the three bytes '<', '^', or '>' to make the text left-, center-, or right-aligned, respectively +/// - *width* is the total width of the field in unicode codepoints /// - *precision* specifies how many decimals a formatted number should have /// /// Note that most of the parameters are optional and may be omitted. Also you can leave out separators like `:` and `.` when |
