Created
April 12, 2019 10:41
-
-
Save Chanutg/fe3a2871aaa68c49955a9a5453785be2 to your computer and use it in GitHub Desktop.
Concat
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
function concat(string memory _base, string memory _value) internal pure returns (string memory) { | |
bytes memory _baseBytes = bytes(_base); | |
bytes memory _valueBytes = bytes(_value); | |
string memory _tmpValue = new string(_baseBytes.length + _valueBytes.length); | |
bytes memory _newValue = bytes(_tmpValue); | |
uint i; | |
uint j; | |
for(i=0; i<_baseBytes.length; i++) { | |
_newValue[j++] = _baseBytes[i]; | |
} | |
for(i=0; i<_valueBytes.length; i++) { | |
_newValue[j++] = _valueBytes[i]; | |
} | |
return string(_newValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment