Wondering if its possible to convert between string memory and string calldata in order to use indexing of the form string[start : end] which only works string calldata. This function seems to works:
function splice(string calldata source, int startPos, int numchars) public pure returns(string memory) {
if (startPos > int(length(sourcestring))) return "";
int start = startPos -1;
int end = startPos + (numchars -1);
string memory retval = string(source[uint(start) : uint(end)]);
return retval;
}
but if I change the parameter source to string memory, then I get an error on
string memory retval = string(source([uint(start) : uint(end)])
because apparently the form sourcestring[start : end] to get a substring works on calldata strings not on memory strings, and there is no obvious way to convert a string memory to a string calldata.
Is there any means to do this?