[formatter] add 'Lb' format specifier - 'L' for bytes

This commit is contained in:
Mike Fährmann
2025-11-03 13:22:39 +01:00
parent 91a5fd85db
commit 5591a16cd7
3 changed files with 38 additions and 8 deletions

View File

@@ -293,6 +293,16 @@ Format specifiers can be used for advanced formatting by using the options provi
<td><code>{foo:L3/long/}</code></td>
<td><code>long</code></td>
</tr>
<tr>
<td rowspan="2"><code>Lb&lt;maxlen&gt;/&lt;ext&gt;/</code></td>
<td rowspan="2">Same as <code>L</code>, but applies to the <a href="https://docs.python.org/3/library/stdtypes.html#bytes"><code>bytes()</code></a> representation of a string in <a href="https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding">filesystem encoding</a></td>
<td><code>{foo_ja:Lb15/長い/}</code></td>
<td><code>フー・バー</code></td>
</tr>
<tr>
<td><code>{foo_ja:Lb8/長い/}</code></td>
<td><code>長い</code></td>
</tr>
<tr>
<td rowspan="2"><code>X&lt;maxlen&gt;/&lt;ext&gt;/</code></td>
<td rowspan="2">Limit output to <code>&lt;maxlen&gt;</code> characters. Cut output and add <code>&lt;ext&gt;</code> to its end if its length exceeds <code>&lt;maxlen&gt;</code></td>