Hi, is there any chance that I can get bytes strin...
# getting-started
x
Hi, is there any chance that I can get bytes string or bytes array from hex string? I mean , get`"00001111"` or
[0,0,0,0,1,1,1,1]
from
"08"
?
j
Hello, does something like
println("08".toInt(radix = 16).toString(radix = 2))
suit your needs ? You can also add some padding for the leading zeroes.
👍 1
x
I'm sorry I mean
"00001000"
or
"[0,0,0,0,1,0,0,0]"
w
Copy code
"08".toBigInteger(16).toString(2).padStart(8, '0')
Tip: these kind of questions are perfect for asking ChatGPT or friends
1
👍 1
j
The
BigInteger
looks a bit overkill here 🙂.
w
True, but I don't know the usecase
k
What is your use case? I'm asking because you ask for a "bytes string" but there's no such thing: "00001000" is a char string.
1