Added `isValidText(string)` method to return whether a given string is valid as in not containing any invalid illegal characters

This commit is contained in:
Tristan B. Velloza Kildaire 2022-11-07 09:23:18 +02:00
parent 3e01ef17d6
commit f5b0fe5118
1 changed files with 22 additions and 0 deletions

View File

@ -45,6 +45,28 @@ public static string decodeMessage(ubyte[] messageIn)
// return null;
}
/**
* Checks if the provided message is valid (i.e.)
* does not contain any CR or LF characters in it
*
* Params:
* message = the message to test
* Returns: <code>true</code> if the message is valid,
* <code>false</code> false otherwise
*/
public static bool isValidText(string message)
{
foreach(char character; message)
{
if(character == 13 || character == 10)
{
return false;
}
}
return true;
}
/**
* Message types
*/