isValidNicknameCharacter

Returns whether or not a passed char can be part of a nickname.

The IRC standard describes nicknames as being a string of any of the following characters:

[a-z] [A-Z] [0-9] _-\\[]{}^\|`

pure @safe nothrow @nogc
isValidNicknameCharacter
(
const ubyte c
)

Parameters

c ubyte

Character to compare with the list of accepted characters in a nickname.

Return Value

Type: auto

true if the character is in the list of valid characters for nicknames, false if not.

Examples

assert('a'.isValidNicknameCharacter);
assert('9'.isValidNicknameCharacter);
assert('`'.isValidNicknameCharacter);
assert(!(' '.isValidNicknameCharacter));
import std.string : representation;

{
    enum line = "abcDEFghi0{}29304_[]`\\^|---";
    foreach (immutable char c; line.representation)
    {
        assert(c.isValidNicknameCharacter, c ~ "");
    }
}
{
    enum line = "åÄö高所恐怖症123なにぬねの ";
    foreach (immutable char c; line.representation)
    {
        assert(!c.isValidNicknameCharacter, c ~ "");
    }
}

Meta