pragma solidity ^0.4.24;

contract Utils {
        
//==============================string工具函数==============================
    function strIsEmpty(string memory str) 
    public pure 
    returns (bool) {
        bytes memory bytesStr = bytes(str);
        return bytesStr.length == 0;
    }
    
    function strIsEqual(string memory str1, string memory str2) 
    public pure 
    returns (bool) {
        if (bytes(str1).length != bytes(str2).length) {
        return false;
        } else {
            return keccak256(abi.encodePacked(str1)) == keccak256(abi.encodePacked(str2));
        }
    }



    function toString(address account) public pure returns (string memory) {
        return toString(abi.encodePacked(account));
    }

    function toString(uint256 value) public pure returns (string memory) {
        return toString(abi.encodePacked(value));
    }

    function toString(bytes32 value) public pure returns (string memory) {
        return toString(abi.encodePacked(value));
    }

    function toString(bytes memory data) public pure returns (string memory) {
        bytes memory alphabet = "0123456789abcdef";

        bytes memory str = new bytes(2 + data.length * 2);
        str[0] = "0";
        str[1] = "x";
        for (uint i = 0; i < data.length; i++) {
            str[2 + i * 2] = alphabet[uint(uint8(data[i] >> 4))];
            str[3 + i * 2] = alphabet[uint(uint8(data[i] & 0x0f))];
        }
        return string(str);
    }
}