Skip to content

LWG Poll 14: P1868R2 🦄 width: clarifying units of width and precision in std::format #3753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions source/intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
\begin{itemize}
\item Ecma International, \doccite{ECMAScript Language Specification},
Standard Ecma-262, third edition, 1999.
% FIXME: Is the following comment refering to the entry above or
% the entry removed in LWG3319? I.e. is it still valid?
%%% Format for this entry is based on that specified at
%%% http://www.iec.ch/standardsdev/resources/draftingpublications/directives/principles/referencing.htm
\item ISO/IEC 2382 (all parts), \doccite{Information technology ---
Vocabulary}
\item ISO 8601:2004, \doccite{Data elements and interchange formats ---
Expand All @@ -56,6 +52,11 @@
\item ISO 80000-2:2009, \doccite{Quantities and units ---
Part 2: Mathematical signs and symbols
to be used in the natural sciences and technology}
%%% Format for the following entry is based on that specified at
%%% http://www.iec.ch/standardsdev/resources/draftingpublications/directives/principles/referencing.htm
\item The Unicode Consortium. Unicode Standard Annex, UAX \#29, \doccite{Unicode Text Segmentation} [online].
Edited by Mark Davis. Revision 35; issued for Unicode 12.0.0. 2019-02-15 [viewed 2020-02-23].
Available at \url{http://www.unicode.org/reports/tr29/tr29-35.html}
\end{itemize}

\pnum
Expand Down Expand Up @@ -681,5 +682,8 @@
\pnum
ECMAScript\textregistered\ is a registered trademark of Ecma International.

\pnum
Unicode\textregistered\ is a registered trademark of Unicode, Inc.

\pnum
All rights in these originals are reserved.
55 changes: 54 additions & 1 deletion source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19371,6 +19371,53 @@
there is no minimum field width, and
the field width is determined based on the content of the field.

\pnum
\indextext{string!width}%
The \defn{width} of a string is defined as
the estimated number of column positions appropriate
for displaying it in a terminal.
\begin{note}
This is similar to the semantics of the POSIX \tcode{wcswidth} function.
\end{note}

\pnum
For the purposes of width computation,
a string is assumed to be in
a locale-independent, implementation-defined encoding.
Implementations should use a Unicode encoding
on platforms capable of displaying Unicode text in a terminal.
\begin{note}
This is the case for Windows-based and many POSIX-based operating systems.
\end{note}

\pnum
For a string in a Unicode encoding,
implementations should estimate the width of a string
as the sum of estimated widths of
the first code points in its extended grapheme clusters
as defined by UAX \#29.
The estimated width of the following code points is 2:
\begin{itemize}
\item \tcode{U+1100-U+115F}
\item \tcode{U+2329-U+232A}
\item \tcode{U+2E80-U+303E}
\item \tcode{U+3040-U+A4CF}
\item \tcode{U+AC00-U+D7A3}
\item \tcode{U+F900-U+FAFF}
\item \tcode{U+FE10-U+FE19}
\item \tcode{U+FE30-U+FE6F}
\item \tcode{U+FF00-U+FF60}
\item \tcode{U+FFE0-U+FFE6}
\item \tcode{U+1F300-U+1F64F}
\item \tcode{U+1F900-U+1F9FF}
\item \tcode{U+20000-U+2FFFD}
\item \tcode{U+30000-U+3FFFD}
\end{itemize}
The estimated width of other code points is 1.

\pnum
For a string in a non-Unicode encoding, the width of a string is unspecified.

\pnum
A zero (\tcode{0}) character
preceding the \fmtgrammarterm{width} field
Expand Down Expand Up @@ -19398,7 +19445,13 @@
the precision or maximum field size.
It can only be used with floating-point and string types.
For floating-point types this field specifies the formatting precision.
For string types it specifies how many characters will be used from the string.
For string types, this field provides an upper bound
for the estimated width of the prefix of
the input string that is copied into the output.
For a string in a Unicode encoding,
the formatter copies to the output
the longest prefix of whole extended grapheme clusters
whose estimated width is no greater than the precision.

\pnum
When the \tcode{L} option is used, the form used for the conversion is called
Expand Down