|
19371 | 19371 | there is no minimum field width, and
|
19372 | 19372 | the field width is determined based on the content of the field.
|
19373 | 19373 |
|
| 19374 | +\pnum |
| 19375 | +\indextext{string!width}% |
| 19376 | +The \defn{width} of a string is defined as |
| 19377 | +the estimated number of column positions appropriate |
| 19378 | +for displaying it in a terminal. |
| 19379 | +\begin{note} |
| 19380 | +This is similar to the semantics of the POSIX \tcode{wcswidth} function. |
| 19381 | +\end{note} |
| 19382 | + |
| 19383 | +\pnum |
| 19384 | +For the purposes of width computation, |
| 19385 | +a string is assumed to be in |
| 19386 | +a locale-independent, implementation-defined encoding. |
| 19387 | +Implementations should use a Unicode encoding |
| 19388 | +on platforms capable of displaying Unicode text in a terminal. |
| 19389 | +\begin{note} |
| 19390 | +This is the case for Windows-based and many POSIX-based operating systems. |
| 19391 | +\end{note} |
| 19392 | + |
| 19393 | +\pnum |
| 19394 | +For a string in a Unicode encoding, |
| 19395 | +implementations should estimate the width of a string |
| 19396 | +as the sum of estimated widths of |
| 19397 | +the first code points in its extended grapheme clusters |
| 19398 | +as defined by UAX \#29. |
| 19399 | +The estimated width of the following code points is 2: |
| 19400 | +\begin{itemize} |
| 19401 | +\item \tcode{U+1100-U+115F} |
| 19402 | +\item \tcode{U+2329-U+232A} |
| 19403 | +\item \tcode{U+2E80-U+303E} |
| 19404 | +\item \tcode{U+3040-U+A4CF} |
| 19405 | +\item \tcode{U+AC00-U+D7A3} |
| 19406 | +\item \tcode{U+F900-U+FAFF} |
| 19407 | +\item \tcode{U+FE10-U+FE19} |
| 19408 | +\item \tcode{U+FE30-U+FE6F} |
| 19409 | +\item \tcode{U+FF00-U+FF60} |
| 19410 | +\item \tcode{U+FFE0-U+FFE6} |
| 19411 | +\item \tcode{U+1F300-U+1F64F} |
| 19412 | +\item \tcode{U+1F900-U+1F9FF} |
| 19413 | +\item \tcode{U+20000-U+2FFFD} |
| 19414 | +\item \tcode{U+30000-U+3FFFD} |
| 19415 | +\end{itemize} |
| 19416 | +The estimated width of other code points is 1. |
| 19417 | + |
| 19418 | +\pnum |
| 19419 | +For a string in a non-Unicode encoding, the width of a string is unspecified. |
| 19420 | + |
19374 | 19421 | \pnum
|
19375 | 19422 | A zero (\tcode{0}) character
|
19376 | 19423 | preceding the \fmtgrammarterm{width} field
|
|
19398 | 19445 | the precision or maximum field size.
|
19399 | 19446 | It can only be used with floating-point and string types.
|
19400 | 19447 | For floating-point types this field specifies the formatting precision.
|
19401 |
| -For string types it specifies how many characters will be used from the string. |
| 19448 | +For string types, this field provides an upper bound |
| 19449 | +for the estimated width of the prefix of |
| 19450 | +the input string that is copied into the output. |
| 19451 | +For a string in a Unicode encoding, |
| 19452 | +the formatter copies to the output |
| 19453 | +the longest prefix of whole extended grapheme clusters |
| 19454 | +whose estimated width is no greater than the precision. |
19402 | 19455 |
|
19403 | 19456 | \pnum
|
19404 | 19457 | When the \tcode{L} option is used, the form used for the conversion is called
|
|
0 commit comments