How can I convert a bytes32
to a string
? Does anyone has a magic function or library which does it?
Solidity String Conversion – How to Convert a Bytes32 to String
bytes32soliditystring
bytes32soliditystring
How can I convert a bytes32
to a string
? Does anyone has a magic function or library which does it?
Best Answer
Based on the latest compiler version 0.4.24, I use the following.
Using explicit conversion to carry it out. The reverse is also possible.
For versions 0.5.0+ please use (tested from 0.5 to 0.7.2 - it is likely that it will continue to work past 0.7.2):