Created
January 28, 2019 21:14
-
-
Save crazyrabbitLTC/8ec42235d1184b90b5666a1d0877b488 to your computer and use it in GitHub Desktop.
LowerCase EVM Package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Original Code: | |
//https://gist.github.com/ottodevs/c43d0a8b4b891ac2da675f825b1d1dbf | |
//Credit: ottodevs | |
//EVM Package: Dennison Bertram, dennison@dennisonbertram.com | |
pragma solidity ^0.4.24; | |
import "zos-lib/contracts/Initializable.sol"; | |
contract LowerCase is Initializable{ | |
uint usage; | |
//set initializer here..... | |
function initialize() { | |
usage = 0; | |
} | |
function _toLower(string memory str) internal returns (string memory) { | |
bytes memory bStr = bytes(str); | |
bytes memory bLower = new bytes(bStr.length); | |
for (uint i = 0; i < bStr.length; i++) { | |
// Uppercase character... | |
if ((bStr[i] >= 65) && (bStr[i] <= 90)) { | |
// So we add 32 to make it lowercase | |
bLower[i] = bytes1(int(bStr[i]) + 32); | |
} else { | |
bLower[i] = bStr[i]; | |
} | |
} | |
usage++; | |
return string(bLower); | |
} | |
function toLower(string str) external returns(string){ | |
return(_toLower(str)); | |
} | |
function usageCount() external view returns(uint){ | |
return usage; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment