ae.utils.text.ascii

Simple (ASCII-only) text-processing functions, for speed and CTFE.

Members

Aliases

ascii
alias ascii = string

Semantic alias for an array of immutable bytes containing some ASCII-based 8-bit character encoding. Might be UTF-8, but not necessarily - thus, is a semantic superset of the D "string" alias.

asciiToLower
alias asciiToLower = _xlat!(asciiLower, char)

Lowercases or uppercases a string in-place.

asciiToUpper
alias asciiToUpper = _xlat!(asciiUpper, char)
Undocumented in source.

Functions

_xlat
void _xlat(T[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.
containsOnlyChars
bool containsOnlyChars(string s, string chars)

Returns true if s does not contain any characters which are not in chars.

fromDec
T fromDec(string s)

Basic string-to-integer conversion. Doesn't check for overflows.

isSignedInteger
bool isSignedInteger(string s)

Returns true if s contains only digits (excluding an optional leading '-') and is non-empty.

isUnsignedInteger
bool isUnsignedInteger(string s)

Returns true if s contains only digits and is non-empty.

toDec
char[] toDec(N o, char[U] buf)

Writes n as decimal number to buf (right-aligned), returns slice of buf containing result.

toDec
string toDec(T n)

Basic integer-to-string conversion.

toDecCTFE
char[] toDecCTFE(N o, char[U] buf)

CTFE-friendly variant.

toDecFixed
void toDecFixed(N n, char[U] buf)
char[U] toDecFixed(N n)

Print an unsigned integer as a zero-padded, right-aligned decimal number into a buffer

Templates

DecimalSize
template DecimalSize(T : ulong)

Maximum number of characters needed to fit the decimal representation of any number of this basic integer type.

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Vladimir Panteleev <ae@cy.md>