https://toitlang.org/ logo
ByteArray stringify and to-string truncation
# help
a
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?
I really should have changed the title of this post :P, not sure where i copy pastad that from
f
You need to write your own function. Something like.
Copy code
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
I will add options to the stringify function.
a
That would be amazing, and thanks for the workaround for now!
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 😉
z
@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