I was wondering if it is possible to convert a bytes32 to a string in solidity like this,
I want an input bytes32 input = 0x74657374
and an output of string output = "0x74657374"
1 Answer
Yes, but you wouldn't want to do that normally.
Generally, don't burden a contract with a client's job. It isn't especially easy to do because bytes
and string
are variable length and therefore require setting aside a word for length. The length of bytes32
requires no such extra internal organization.
Have a look over here: How to convert bytes32 to string?
Hope it helps.