Skip to content

Commit 2d9c479

Browse files
committed
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 473cb1f as well as 279607c, 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
1 parent 559bbf1 commit 2d9c479

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/std/fmt.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pub const FormatOptions = struct {
4040
/// - when using a field name, you are required to enclose the field name (an identifier) in square
4141
/// brackets, e.g. {[score]...} as opposed to the numeric index form which can be written e.g. {2...}
4242
/// - *specifier* is a type-dependent formatting option that determines how a type should formatted (see below)
43-
/// - *fill* is a single character which is used to pad the formatted text
44-
/// - *alignment* is one of the three characters `<`, `^`, or `>` to make the text left-, center-, or right-aligned, respectively
45-
/// - *width* is the total width of the field in characters
43+
/// - *fill* is a single unicode codepoint which is used to pad the formatted text
44+
/// - *alignment* is one of the three bytes '<', '^', or '>' to make the text left-, center-, or right-aligned, respectively
45+
/// - *width* is the total width of the field in unicode codepoints
4646
/// - *precision* specifies how many decimals a formatted number should have
4747
///
4848
/// Note that most of the parameters are optional and may be omitted. Also you can leave out separators like `:` and `.` when

0 commit comments

Comments
 (0)