Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.ascii

Functions which operate on ASCII characters.
All of the functions in std.ascii accept Unicode characters but effectively ignore them if they're not ASCII. All isX functions return false for non-ASCII characters, and all toX functions do nothing to non-ASCII characters.

For functions which operate on Unicode characters, see std.uni.

References: ASCII Table, Wikipedia

License:
Authors:
Walter Bright and Jonathan M Davis

Source: std/ascii.d

immutable string fullHexDigits;
0..9A..Fa..f
immutable string hexDigits;
0..9A..F
immutable string lowerHexDigits;
0..9a..f
immutable string digits;
0..9
immutable string octalDigits;
0..7
immutable string letters;
A..Za..z
immutable string uppercase;
A..Z
immutable string lowercase;
a..z
immutable string whitespace;
ASCII whitespace
enum LetterCase: bool;
Letter case specifier.
upper
Upper case letters
lower
Lower case letters
immutable string newline;
Newline sequence for this system.
pure nothrow @nogc @safe bool isAlphaNum(dchar c);
Returns whether c is a letter or a number (0..9, a..z, A..Z).
pure nothrow @nogc @safe bool isAlpha(dchar c);
Returns whether c is an ASCII letter (A..Z, a..z).
pure nothrow @nogc @safe bool isLower(dchar c);
Returns whether c is a lowercase ASCII letter (a..z).
pure nothrow @nogc @safe bool isUpper(dchar c);
Returns whether c is an uppercase ASCII letter (A..Z).
pure nothrow @nogc @safe bool isDigit(dchar c);
Returns whether c is a digit (0..9).
pure nothrow @nogc @safe bool isOctalDigit(dchar c);
Returns whether c is a digit in base 8 (0..7).
pure nothrow @nogc @safe bool isHexDigit(dchar c);
Returns whether c is a digit in base 16 (0..9, A..F, a..f).
pure nothrow @nogc @safe bool isWhite(dchar c);
Whether or not c is a whitespace character. That includes the space, tab, vertical tab, form feed, carriage return, and linefeed characters.
pure nothrow @nogc @safe bool isControl(dchar c);
Returns whether c is a control character.
pure nothrow @nogc @safe bool isPunctuation(dchar c);
Whether or not c is a punctuation character. That includes all ASCII characters which are not control characters, letters, digits, or whitespace.
pure nothrow @nogc @safe bool isGraphical(dchar c);
Whether or not c is a printable character other than the space character.
pure nothrow @nogc @safe bool isPrintable(dchar c);
Whether or not c is a printable character - including the space character.
pure nothrow @nogc @safe bool isASCII(dchar c);
Whether or not c is in the ASCII character set - i.e. in the range 0..0x7F.
auto toLower(C)(C c) if (is(C : dchar));
If c is an uppercase ASCII character, then its corresponding lowercase letter is returned. Otherwise, c is returned.
C can be any type which implicitly converts to dchar. In the case where it's a built-in type, or an enum of a built-in type, Unqual!(OriginalType!C) is returned, whereas if it's a user-defined type, dchar is returned.
auto toUpper(C)(C c) if (is(C : dchar));
If c is a lowercase ASCII character, then its corresponding uppercase letter is returned. Otherwise, c is returned.
C can be any type which implicitly converts to dchar. In the case where it's a built-in type, or an enum of a built-in type, Unqual!(OriginalType!C) is returned, whereas if it's a user-defined type, dchar is returned.