Skip to content

Commit

Permalink
Further changes from Tom.
Browse files Browse the repository at this point in the history
  • Loading branch information
brevzin committed May 9, 2022
1 parent b6f51f3 commit 6745d72
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 77 deletions.
14 changes: 6 additions & 8 deletions 2286_fmt_ranges/fmt-ranges.md
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,11 @@ Add a new clause [format.string.escaped] "Formatting escaped characters and stri
::: addu
[1]{.pnum} A character or string can be formatted as _escaped_ to make it more suitable for debugging or for logging.

[2]{.pnum} The escaped string `$E$` representation of a string `$S$` is constructed by encoding a sequence of characters in the associated character encoding `$CE$` for `charT` ([lex.string.literal]) as follows:
[2]{.pnum} The escaped string `$E$` representation of a string `$S$` is constructed by encoding a sequence of characters as follows. The associated character encoding `$CE$` for `charT` ([lex.string.literal]) is used to both interpret `$S$` and construct `$E$`.

* [2.#]{.pnum} U+0022 QUOTATION MARK (`"`) is appended to `$E$`

* [2.#]{.pnum} For each code sequence `$X$` in `$S$` that either encodes a single character, encodes a state transition, or is a sequence of ill-formed code units, processing is in order as follows:
* [2.#]{.pnum} For each code unit sequence `$X$` in `$S$` that either encodes a single character, encodes a state transition, or is a sequence of ill-formed code units, processing is in order as follows:

* [2.#]{.pnum} If `$X$` encodes a single character `$C$`, then:

Expand All @@ -1299,24 +1299,22 @@ Add a new clause [format.string.escaped] "Formatting escaped characters and stri
* [2.#.#]{.pnum} `$CE$` is a Unicode encoding and `$C$` corresponds to either a UCS scalar value whose Unicode property `General_Category` has a value in the groups `Separator` (`Z`) or `Other` (`C`) or to a UCS scalar value which has the Unicode property `Grapheme_Extend=Yes`, as described by table 12 of UAX#44, or
* [2.#.#]{.pnum} `$CE$` is not a Unicode encoding and `$C$` is one of an implementation-defined set of separator or non-printable characters

then the sequence `\u{$hex-digit-sequence$}` is appended to `$E$`, where `$hex-digit-sequence$` is the shortest hexadecimal representation of `$C$` using lower-case `$hexadecimal-digit$`s.
then the sequence `\u{$hex-digit-sequence$}` is appended to `$E$`, where `$hex-digit-sequence$` is the shortest hexadecimal representation of `$C$` using lower-case hexadecimal digits.

* [2.#.#]{.pnum} Otherwise, `$C$` is appended to `$E$`.

* [2.#]{.pnum} Otherwise, if `$X$` encodes a state transition, the effect on `$E$` is unspecified.
* [2.#]{.pnum} Otherwise, if `$X$` encodes a state transition, the effect on `$E$` is unspecified. [ *Note*: the intent is that a state transition be represented in `$E$` such that its original code unit sequence can be reconstructed -*end note* ]

* [2.#]{.pnum} Otherwise (`$X$` is a sequence of ill-formed code units), each code unit `$U$` is appended to `$E$` in order as the sequence `\x{$hex-digit-sequence$}`, where `$hex-digit-sequence$` is the shortest hexadecimal representation of `$U$` using lower-case `$hexadecimal-digit$`s. When encoding a stateful character encoding, these additions should have no effect on encoding state.
* [2.#]{.pnum} Otherwise (`$X$` is a sequence of ill-formed code units), each code unit `$U$` is appended to `$E$` in order as the sequence `\x{$hex-digit-sequence$}`, where `$hex-digit-sequence$` is the shortest hexadecimal representation of `$U$` using lower-case hexadecimal digits.

* [2.#]{.pnum} Finally, U+0022 QUOTATION MARK (`"`) is appended to `$E$`.

[3]{.pnum} The escaped character representation of a character `$C$` in a Unicode encoding is equivalent to the escaped string representation of a string of `$C$`, except that:
[3]{.pnum} The escaped string representation of a character `$C$` is equivalent to the escaped string representation of a string of `$C$`, except that:

* [3.#]{.pnum} the result starts and ends with U+0027 APOSTROPHE (`'`) instead of U+0022 QUOTATION MARK (`"`), and
* [3.#]{.pnum} if `$C$` is U+0027 APOSTROPHE, the two characters `\'` are appended to `$E$`, and
* [3.#]{.pnum} if `$C$` is U+0022 QUOTATION MARK, then `$C$` is appended unchanged.

[4]{.pnum} The escaped character and escaped string representations of a character or string in a non-Unicode encoding is unspecified.

[*Example*:
```
string s0 = format("[{}]", "h\tllo"); // s0 has value: [h llo]
Expand Down
Loading

0 comments on commit 6745d72

Please sign in to comment.