mirror of
https://github.com/status-im/github-oracle.git
synced 2026-08-27 09:51:10 +00:00
25 lines
667 B
Solidity
25 lines
667 B
Solidity
pragma solidity ^0.4.0;
|
|
|
|
library Bytes32Lib {
|
|
|
|
function toString(bytes32 self) internal constant returns (string) {
|
|
bytes memory bytesString = new bytes(32);
|
|
uint charCount = 0;
|
|
for (uint j = 0; j < 32; j++) {
|
|
byte char = byte(bytes32(uint(self) * 2 ** (8 * j)));
|
|
if (char != 0) {
|
|
bytesString[charCount] = char;
|
|
charCount++;
|
|
}
|
|
}
|
|
bytes memory bytesStringTrimmed = new bytes(charCount);
|
|
for (j = 0; j < charCount; j++) {
|
|
bytesStringTrimmed[j] = bytesString[j];
|
|
}
|
|
return string(bytesStringTrimmed);
|
|
}
|
|
|
|
|
|
|
|
|
|
} |