From Jason Turner

[format.string.std]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp19b33ecm/{from.md → to.md} +20 -16
tmp/tmp19b33ecm/{from.md → to.md} RENAMED
@@ -48,11 +48,11 @@ precision
48
  '.' '{' arg-idₒₚₜ '}'
49
  ```
50
 
51
  ``` bnf
52
  type one of
53
- 'a A b B c d e E f F g G o p s x X ?'
54
  ```
55
 
56
  Field widths are specified in *field width units*; the number of column
57
  positions required to display a sequence of characters in a terminal.
58
  The *minimum field width* is the number of field width units a
@@ -95,20 +95,22 @@ string s5 = format("{:6d}", c); // value of s5 is "\ \ \ 120"
95
  string s6 = format("{:6}", true); // value of s6 is "true\ \ "
96
  string s7 = format("{:*<6.3}", "123456"); // value of s7 is "123***"
97
  string s8 = format("{:02}", 1234); // value of s8 is "1234"
98
  string s9 = format("{:*<}", "12"); // value of s9 is "12"
99
  string sA = format("{:*<6}", "12345678"); // value of sA is "12345678"
 
 
100
  ```
101
 
102
  — *end example*]
103
 
104
  [*Note 4*: The *fill*, *align*, and `0` options have no effect when the
105
  minimum field width is not greater than the estimated field width
106
  because padding width is `0` in that case. Since fill characters are
107
  assumed to have a field width of `1`, use of a character with a
108
  different field width can produce misaligned output. The
109
- U+1f921 (clown face) character has a field width of `2`. The examples
110
  above that include that character illustrate the effect of the field
111
  width when that character is used as a fill character as opposed to when
112
  it is used as a formatting argument. — *end note*]
113
 
114
  **Table: Meaning of align options** <a id="format.align">[format.align]</a>
@@ -160,15 +162,16 @@ contain a decimal-point character, even if no digits follow it.
160
  Normally, a decimal-point character appears in the result of these
161
  conversions only if a digit follows it. In addition, for `g` and `G`
162
  conversions, trailing zeros are not removed from the result.
163
 
164
  The `0` option is valid for arithmetic types other than `charT` and
165
- `bool` or when an integer presentation type is specified. For formatting
166
- arguments that have a value other than an infinity or a NaN, this option
167
- pads the formatted argument by inserting the `0` character n times
168
- following the sign or base prefix indicators (if any) where n is `0` if
169
- the *align* option is present and is the padding width otherwise.
 
170
 
171
  [*Example 3*:
172
 
173
  ``` cpp
174
  char c = 120;
@@ -183,13 +186,13 @@ string s4 = format("{:06}", inf); // value of s4 is "\ \ \ inf" (0 has no
183
  The *width* option specifies the minimum field width. If the *width*
184
  option is absent, the minimum field width is `0`.
185
 
186
  If `{ \opt{arg-id} }` is used in a *width* or *precision* option, the
187
  value of the corresponding formatting argument is used as the value of
188
- the option. If the corresponding formatting argument is not of standard
189
- signed or unsigned integer type, or its value is negative, an exception
190
- of type `format_error` is thrown.
191
 
192
  If *positive-integer* is used in a *width* option, the value of the
193
  *positive-integer* is interpreted as a decimal integer and used as the
194
  value of the option.
195
 
@@ -198,25 +201,25 @@ locale-independent, *implementation-defined* encoding. Implementations
198
  should use either UTF-8, UTF-16, or UTF-32, on platforms capable of
199
  displaying Unicode text in a terminal.
200
 
201
  [*Note 5*:
202
 
203
- This is the case for Windows[^2]
204
 
205
- -based and many POSIX-based operating systems.
206
 
207
  — *end note*]
208
 
209
  For a sequence of characters in UTF-8, UTF-16, or UTF-32, an
210
  implementation should use as its field width the sum of the field widths
211
  of the first code point of each extended grapheme cluster. Extended
212
  grapheme clusters are defined by UAX \#29 of the Unicode Standard. The
213
  following code points have a field width of 2:
214
 
215
  - any code point with the `East_Asian_Width="W"` or
216
- `East_Asian_Width="F"` Derived Extracted Property as described by UAX
217
- \#44 of the Unicode Standard
218
  - `U+4dc0` – `U+4dff` (Yijing Hexagram Symbols)
219
  - `U+1f300` – `U+1f5ff` (Miscellaneous Symbols and Pictographs)
220
  - `U+1f900` – `U+1f9ff` (Supplemental Symbols and Pictographs)
221
 
222
  The field width of all other code points is 1.
@@ -306,13 +309,13 @@ The available `charT` presentation types are specified in
306
  [[format.type.char]].
307
 
308
  **Table: Meaning of type options for `charT`** <a id="format.type.char">[format.type.char]</a>
309
 
310
  | Type | Meaning |
311
- | ------------------------------ | --------------------------------------------------------------------- |
312
  | none, `c` | Copies the character to the output. |
313
- | % `b`, `B`, `d`, `o`, `x`, `X` | As specified in [[format.type.int]]. |
314
  | % `?` | Copies the escaped character [[format.string.escaped]] to the output. |
315
 
316
 
317
  The available `bool` presentation types are specified in
318
  [[format.type.bool]].
@@ -358,7 +361,8 @@ are specified in [[format.type.ptr]].
358
  **Table: Meaning of type options for pointer types** <a id="format.type.ptr">[format.type.ptr]</a>
359
 
360
  | Type | Meaning |
361
  | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
362
  | none, `p` | If `uintptr_t` is defined, \begin{codeblock} to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16) \end{codeblock} with the prefix `0x` inserted immediately before the output of `to_chars`; otherwise, implementation-defined. |
 
363
 
364
 
 
48
  '.' '{' arg-idₒₚₜ '}'
49
  ```
50
 
51
  ``` bnf
52
  type one of
53
+ 'a A b B c d e E f F g G o p P s x X ?'
54
  ```
55
 
56
  Field widths are specified in *field width units*; the number of column
57
  positions required to display a sequence of characters in a terminal.
58
  The *minimum field width* is the number of field width units a
 
95
  string s6 = format("{:6}", true); // value of s6 is "true\ \ "
96
  string s7 = format("{:*<6.3}", "123456"); // value of s7 is "123***"
97
  string s8 = format("{:02}", 1234); // value of s8 is "1234"
98
  string s9 = format("{:*<}", "12"); // value of s9 is "12"
99
  string sA = format("{:*<6}", "12345678"); // value of sA is "12345678"
100
+ string sB = format("{:\importexample[-2pt]{example_05}\kern0.75pt^6}", "x"); // value of sB is "\importexample[-2pt]{example_05\importexample[-2pt]{example_05}x\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
101
+ string sC = format("{:*^6}", "\importexample[-2pt]{example_05}\kern0.75pt\importexample[-2pt]{example_05}\kern0.75pt\importexample[-2pt]{example_05}\kern0.75pt"); // value of sC is "\importexample[-2pt]{example_05\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
102
  ```
103
 
104
  — *end example*]
105
 
106
  [*Note 4*: The *fill*, *align*, and `0` options have no effect when the
107
  minimum field width is not greater than the estimated field width
108
  because padding width is `0` in that case. Since fill characters are
109
  assumed to have a field width of `1`, use of a character with a
110
  different field width can produce misaligned output. The
111
+ (U+1f921 (clown face)) character has a field width of `2`. The examples
112
  above that include that character illustrate the effect of the field
113
  width when that character is used as a fill character as opposed to when
114
  it is used as a formatting argument. — *end note*]
115
 
116
  **Table: Meaning of align options** <a id="format.align">[format.align]</a>
 
162
  Normally, a decimal-point character appears in the result of these
163
  conversions only if a digit follows it. In addition, for `g` and `G`
164
  conversions, trailing zeros are not removed from the result.
165
 
166
  The `0` option is valid for arithmetic types other than `charT` and
167
+ `bool`, pointer types, or when an integer presentation type is
168
+ specified. For formatting arguments that have a value other than an
169
+ infinity or a NaN, this option pads the formatted argument by inserting
170
+ the `0` character n times following the sign or base prefix indicators
171
+ (if any) where n is `0` if the *align* option is present and is the
172
+ padding width otherwise.
173
 
174
  [*Example 3*:
175
 
176
  ``` cpp
177
  char c = 120;
 
186
  The *width* option specifies the minimum field width. If the *width*
187
  option is absent, the minimum field width is `0`.
188
 
189
  If `{ \opt{arg-id} }` is used in a *width* or *precision* option, the
190
  value of the corresponding formatting argument is used as the value of
191
+ the option. The option is valid only if the corresponding formatting
192
+ argument is of standard signed or unsigned integer type. If its value is
193
+ negative, an exception of type `format_error` is thrown.
194
 
195
  If *positive-integer* is used in a *width* option, the value of the
196
  *positive-integer* is interpreted as a decimal integer and used as the
197
  value of the option.
198
 
 
201
  should use either UTF-8, UTF-16, or UTF-32, on platforms capable of
202
  displaying Unicode text in a terminal.
203
 
204
  [*Note 5*:
205
 
206
+ This is the case for Windows®-based[^25]
207
 
208
+ and many POSIX-based operating systems.
209
 
210
  — *end note*]
211
 
212
  For a sequence of characters in UTF-8, UTF-16, or UTF-32, an
213
  implementation should use as its field width the sum of the field widths
214
  of the first code point of each extended grapheme cluster. Extended
215
  grapheme clusters are defined by UAX \#29 of the Unicode Standard. The
216
  following code points have a field width of 2:
217
 
218
  - any code point with the `East_Asian_Width="W"` or
219
+ `East_Asian_Width="F"` property as described by UAX \#44 of the
220
+ Unicode Standard
221
  - `U+4dc0` – `U+4dff` (Yijing Hexagram Symbols)
222
  - `U+1f300` – `U+1f5ff` (Miscellaneous Symbols and Pictographs)
223
  - `U+1f900` – `U+1f9ff` (Supplemental Symbols and Pictographs)
224
 
225
  The field width of all other code points is 1.
 
309
  [[format.type.char]].
310
 
311
  **Table: Meaning of type options for `charT`** <a id="format.type.char">[format.type.char]</a>
312
 
313
  | Type | Meaning |
314
+ | ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
315
  | none, `c` | Copies the character to the output. |
316
+ | % `b`, `B`, `d`, `o`, `x`, `X` | As specified in [[format.type.int]] with `value` converted to the unsigned version of the underlying type. |
317
  | % `?` | Copies the escaped character [[format.string.escaped]] to the output. |
318
 
319
 
320
  The available `bool` presentation types are specified in
321
  [[format.type.bool]].
 
361
  **Table: Meaning of type options for pointer types** <a id="format.type.ptr">[format.type.ptr]</a>
362
 
363
  | Type | Meaning |
364
  | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
365
  | none, `p` | If `uintptr_t` is defined, \begin{codeblock} to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16) \end{codeblock} with the prefix `0x` inserted immediately before the output of `to_chars`; otherwise, implementation-defined. |
366
+ | `P` | The same as `p`, except that it uses uppercase letters for digits above `9` and the base prefix is `0X`. |
367
 
368