Bug 21843 – std.format could support %{x,X} for ubyte[]

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-18T18:22:47Z
Last change time
2024-12-01T16:38:44Z
Assigned to
No Owner
Creator
Mathias LANG
Moved to GitHub: phobos#9821 →

Comments

Comment #0 by pro.mathias.lang — 2021-04-18T18:22:47Z
``` import std; void main () { ubyte[] data = [42, 69, 250]; writefln("%X", data); } ``` This currently throws an Exception. I think it could print `2A45FA`. This would be very handy to save on space when printing large ubyte arrays. This is an enhancement request, as there is nothing wrong with the current behavior.
Comment #1 by bugzilla — 2021-04-19T15:52:25Z
You can use writefln!"%(%02X%)"(data); to get the desired result. (But %X might be useful as a shortcut, so leaving this open.)
Comment #2 by robert.schadek — 2024-12-01T16:38:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9821 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB