The 7-bit ASCII character encoding standard.

This is not to be confused with the 8-bit extended ASCII character encoding.

Even though this module concerns itself with 7-bit ASCII, functions use u8 as the type instead of u7 for convenience and compatibility. Characters outside of the 7-bit range are gracefully handled (e.g. by returning false).

See also: https://en.wikipedia.org/wiki/ASCII#Character_set

Namespaces

Functions

fn allocLowerString(allocator: std.mem.Allocator, ascii_string: []const u8) ![]u8

Allocates a lower case copy of ascii_string. Caller owns returned string and …

Allocates a lower case copy of ascii_string. Caller owns returned string and must free with allocator.

fn allocUpperString(allocator: std.mem.Allocator, ascii_string: []const u8) ![]u8

Allocates an upper case copy of ascii_string. Caller owns returned string and…

Allocates an upper case copy of ascii_string. Caller owns returned string and must free with allocator.

fn endsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool

No documentation provided.

fn eqlIgnoreCase(a: []const u8, b: []const u8) bool

Compares strings a and b case-insensitively and returns whether they are equ…

Compares strings a and b case-insensitively and returns whether they are equal.

fn indexOfIgnoreCase(haystack: []const u8, needle: []const u8) ?usize

Finds needle in haystack, ignoring case, starting at index 0.

fn indexOfIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize

Finds needle in haystack, ignoring case, starting at start_index. Uses Bo…

Finds needle in haystack, ignoring case, starting at start_index. Uses Boyer-Moore-Horspool algorithm on large inputs; indexOfIgnoreCasePosLinear on small inputs.

fn indexOfIgnoreCasePosLinear(haystack: []const u8, start_index: usize, needle: []const u8) ?usize

Consider using indexOfIgnoreCasePos instead of this, which will automatically …

Consider using indexOfIgnoreCasePos instead of this, which will automatically use a more sophisticated algorithm on larger inputs.

fn isASCII(c: u8) bool

Returns whether the character is a 7-bit ASCII character.

fn isAlphabetic(c: u8) bool

Returns whether the character is alphabetic: A-Z or a-z.

fn isAlphanumeric(c: u8) bool

Returns whether the character is alphanumeric: A-Z, a-z, or 0-9.

fn isControl(c: u8) bool

Returns whether the character is a control character.

Returns whether the character is a control character.

See also: control_code

fn isDigit(c: u8) bool

Returns whether the character is a digit.

fn isHex(c: u8) bool

Returns whether the character is a hexadecimal digit: A-F, a-f, or 0-9.

fn isLower(c: u8) bool

Returns whether the character is a lowercase letter.

fn isPrint(c: u8) bool

Returns whether the character is printable and has some graphical representation…

Returns whether the character is printable and has some graphical representation, including the space character.

fn isUpper(c: u8) bool

Returns whether the character is an uppercase letter.

fn isWhitespace(c: u8) bool

Returns whether this character is included in whitespace.

fn lessThanIgnoreCase(lhs: []const u8, rhs: []const u8) bool

Returns whether the lexicographical order of lhs is lower than rhs.

fn lowerString(output: []u8, ascii_string: []const u8) []u8

Writes a lower case copy of ascii_string to output. Asserts `output.len >= …

Writes a lower case copy of ascii_string to output. Asserts output.len >= ascii_string.len.

fn orderIgnoreCase(lhs: []const u8, rhs: []const u8) std.math.Order

Returns the lexicographical order of two slices. O(n).

fn startsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool

No documentation provided.

fn toLower(c: u8) u8

Lowercases the character and returns it as-is if already lowercase or not a lett…

Lowercases the character and returns it as-is if already lowercase or not a letter.

fn toUpper(c: u8) u8

Uppercases the character and returns it as-is if already uppercase or not a lett…

Uppercases the character and returns it as-is if already uppercase or not a letter.

fn upperString(output: []u8, ascii_string: []const u8) []u8

Writes an upper case copy of ascii_string to output. Asserts `output.len >=…

Writes an upper case copy of ascii_string to output. Asserts output.len >= ascii_string.len.

Values

whitespace
[6]u8

Whitespace for general use. This may be used with e.g. std.mem.trim to trim w…