guild icon
Toit
#ByteArray stringify and to-string truncation
Thread channel in help
addshore
addshore 01/30/2025 11:15 AM
I'm calling stringify or to-string on a ByteArray, and the output is getting truncated at the end, ie 0xf0, 0x7f, ...]
I moved from stringify to to-string thinking it might solve my issue, as it has a from and to, that defaults to the full size, but it is still truncated.
Is there any "easy" way to print the whole thing?
addshore
addshore 01/30/2025 11:16 AM
I really should have changed the title of this post :P, not sure where i copy pastad that from
floitsch
floitsch 01/30/2025 11:21 AM
You need to write your own function. Something like.

buffer := io.Buffer is-first := true bytes.do: if is-first: is-first = false else: buffer.write ", " buffer.write "0x$(%02x it)" result := buffer.to-string
👍1
floitsch
floitsch 01/30/2025 11:24 AM
I will add options to the stringify function.
💟1
addshore
addshore 01/30/2025 11:26 AM
That would be amazing, and thanks for the workaround for now!
addshore
addshore 01/30/2025 11:27 AM
for my own personal usecase, I'd love to be able to change the format of stirngify for bytes too, but perhaps that best left to my own code :😉:
z3ugma
z3ugma 02/02/2025 06:49 PM
@addshore I usually print out the shortened array and write the full bytearray to a file which lets me reference it later, in case you're open to another idea
👍1
8 messages in total