add helper functions chars

console-destruction
Maikel de Vries 2016-09-06 16:57:28 +02:00
parent a882a6e64b
commit 17f98bd235
1 changed files with 31 additions and 1 deletions

View File

@ -19,4 +19,34 @@ global func TakeString(string str, int begin, int end)
for (var index = begin; index < end; index++)
reduced_str = Format("%s%c", reduced_str, GetChar(str, index));
return reduced_str;
}
}
// Converts a char into a string.
global func CharToString(int char)
{
return Format("%c", char);
}
// Returns whether a char is a digit [0-9].
global func CharIsDigit(int char)
{
return Inside(char, 48, 57);
}
// Returns whether a char is a letter [A-Za-z].
global func CharIsLetter(int char)
{
return CharIsLowerCase(char) || CharIsUpperCase(char);
}
// Returns whether a char is a lower-case letter [a-z].
global func CharIsLowerCase(int char)
{
return Inside(char, 97, 122);
}
// Returns whether a char is an upper-case letter [A-Z].
global func CharIsUpperCase(int char)
{
return Inside(char, 65, 90);
}