|
1 | 1 | %!TEX root = std.tex
|
| 2 | + |
2 | 3 | \rSec0[utilities]{General utilities library}
|
3 | 4 |
|
4 | 5 | \rSec1[utilities.general]{General}
|
|
15915 | 15916 | string s8 = format("{:02}", 1234); // value of \tcode{s8} is \tcode{"1234"}
|
15916 | 15917 | string s9 = format("{:*<}", "12"); // value of \tcode{s9} is \tcode{"12"}
|
15917 | 15918 | string sA = format("{:*<6}", "12345678"); // value of \tcode{sA} is \tcode{"12345678"}
|
| 15919 | +string sB = format("{:@\importexample[-2pt]{example_05}\caret{}@6}", "x"); // value of \tcode{sB} is \tcode{"\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}x\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"} |
| 15920 | +string sC = format("{:*@\caret{}@6}", "@\importexample[-2pt]{example_05}@"); // value of \tcode{sC} is \tcode{"\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"} |
15918 | 15921 | \end{codeblock}
|
15919 | 15922 | \end{example}
|
15920 | 15923 | \begin{note}
|
|
15924 | 15927 | because padding width is \tcode{0} in that case.
|
15925 | 15928 | Since fill characters are assumed to have a field width of \tcode{1},
|
15926 | 15929 | use of a character with a different field width can produce misaligned output.
|
15927 |
| -%FIXME: cannot show clown face character below. |
15928 |
| -The \unicode{1f921}{clown face} character has a field width of \tcode{2}. |
| 15930 | +The \importexample[-2pt]{example_05} (\unicode{1f921}{clown face}) character has a field width of \tcode{2}. |
15929 | 15931 | The examples above that include that character
|
15930 | 15932 | illustrate the effect of the field width
|
15931 | 15933 | when that character is used as a fill character
|
@@ -17142,16 +17144,19 @@
|
17142 | 17144 | %% FIXME: their Unicode characters are not available in our font (Latin Modern).
|
17143 | 17145 | \begin{example}
|
17144 | 17146 | \begin{codeblock}
|
17145 |
| -string s0 = format("[{}]", "h\tllo"); // \tcode{s0} has value: \tcode{[h\ \ \ \ llo]} |
17146 |
| -string s1 = format("[{:?}]", "h\tllo"); // \tcode{s1} has value: \tcode{["h\textbackslash tllo"]} |
17147 |
| -string s3 = format("[{:?}, {:?}]", '\'', '"'); // \tcode{s3} has value: \tcode{['\textbackslash '', '"']} |
| 17147 | +string s0 = format("[{}]", "h\tllo"); // \tcode{s0} has value: \tcode{[h\ \ \ \ llo]} |
| 17148 | +string s1 = format("[{:?}]", "h\tllo"); // \tcode{s1} has value: \tcode{["h\textbackslash tllo"]} |
| 17149 | +string s2 = format("[{:?}]", "@\importexample[-2.5pt]{example_01}@"); @\kern1.25pt@// \tcode{s2} has value: \tcode{["\importexample[-2.5pt]{example_01}"]} |
| 17150 | +string s3 = format("[{:?}, {:?}]", '\'', '"'); // \tcode{s3} has value: \tcode{['\textbackslash '', '"']} |
17148 | 17151 |
|
17149 | 17152 | // The following examples assume use of the UTF-8 encoding
|
17150 | 17153 | string s4 = format("[{:?}]", string("\0 \n \t \x02 \x1b", 9));
|
17151 | 17154 | // \tcode{s4} has value: \tcode{["\textbackslash u\{0\} \textbackslash n \textbackslash t \textbackslash u\{2\} \textbackslash u\{1b\}"]}
|
17152 | 17155 | string s5 = format("[{:?}]", "\xc3\x28"); // invalid UTF-8, \tcode{s5} has value: \tcode{["\textbackslash x\{c3\}("]}
|
| 17156 | +string s6 = format("[{:?}]", "@\importexample{example_02}@"); @\kern0.75pt@// \tcode{s6} has value: \tcode{["\importexample{example_03}\textbackslash{u}\{200d\}\importexample{example_04}\textbackslash{u}\{fe0f\}"]} |
17153 | 17157 | string s7 = format("[{:?}]", "\u0301"); // \tcode{s7} has value: \tcode{["\textbackslash u{301}"]}
|
17154 | 17158 | string s8 = format("[{:?}]", "\\\u0301"); // \tcode{s8} has value: \tcode{["\textbackslash \textbackslash \textbackslash u{301}"]}
|
| 17159 | +string s9 = format("[{:?}]", "e\u0301\u0323"); // \tcode{s9} has value: \tcode{["\importexample[-2pt]{example_06}"]} |
17155 | 17160 | \end{codeblock}
|
17156 | 17161 | \end{example}
|
17157 | 17162 |
|
|
0 commit comments