Returns true, if a given character is a digit (0-9).

@param string|null $char A single character
@return bool
489810
protected function isDigit($char)
    {
        if ($char === null) {
            return false;
        }

        // Notice: ord(null) will return 0.
        // ord() does not work with utf-8 characters.
        $ascii = ord($char);

        // ASCII codes: 48 = '0', 57 = '9'
        return ($ascii >= 48 and $ascii <= 57);
    }
930420
public static function charNotInAlphabet(string $char) : self
    {
        $ord = \ord($char);

        if ($ord < 32 || $ord > 126) {
            $char = \strtoupper(\dechex($ord));

            if ($ord < 10) {
                $char = '0' . $char;
            }
        } else {
            $char = '"' . $char . '"';
        }

        return new self(sprintf('Char %s is not a valid character in the given alphabet.', $char));
    }
454652
private static boolean isValidChar(char c) {
        if ( c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' ) {
            return true;
        }
        return c != ' ' && c != '\u00A0' && !Character.isWhitespace(c) && !Character.isWhitespace(c);
    }
1253114
public static boolean isDigitsOnly(String s) {
        if (isEmpty(s)) return false;
        String rslt = s.trim();
        if (isEmpty(rslt)) return false;
        for (int i = 0; i < rslt.length(); i++) {
            char ch = rslt.charAt(i);
            if (!Character.isDigit(ch)) return false;
        }
        return true;
    }
646537
public static int hex2bin(char c)
    {
        if (c >= '0' && c <= '9')
        {
            return (c - '0');
        }
        if (c >= 'A' && c <= 'F')
        {
            return (c - 'A' + 10);
        }
        if (c >= 'a' && c <= 'f')
        {
            return (c - 'a' + 10);
        }
        throw new IllegalArgumentException(
                "Input string may only contain hex digits, but found '" + c
                        + "'");
    }
1118064
public static boolean validChar(char toTest) {
        if (toTest >= 'A' && toTest <= 'Z') return true;
        if (toTest >= '0' && toTest <= '9') return true;
        
        return (toTest == '_' || toTest == '^' || toTest == '$' ||
                toTest == '~' || toTest == '!' || toTest == '#' ||
                toTest == '%' || toTest == '&' || toTest == '-' ||
                toTest == '{' || toTest == '}' || toTest == '(' ||
                toTest == ')' || toTest == '@' || toTest == '\''||
                toTest == '`');
    }
483081
public function isValid( $key = null ) {
		$key = $key ? $this->sanitizeKey( $key ) : $this->getKey();
		return strlen( $key ) === 35;
	}
500982
public function hasDigit($digit)
    {
        try {
            $this->digits->getValue($digit);
        } catch (DigitList\InvalidDigitException $ex) {
            return false;
        }

        return true;
    }
626850
public static function getCharDirection($char)
    {
        $c = Strings::ord($char);

        if (!(0x5be <= $c && 0x10b7f >= $c)) {
            return static::LTR;
        }

        if (0x85e >= $c) {
            if (0x5be === $c ||
                0x5c0 === $c ||
                0x5c3 === $c ||
                0x5c6 === $c ||
                (0x5d0 <= $c && 0x5ea >= $c) ||
                (0x5f0 <= $c && 0x5f4 >= $c) ||
                0x608 === $c ||
                0x60b === $c ||
                0x60d === $c ||
                0x61b === $c ||
                (0x61e <= $c && 0x64a >= $c) ||
                (0x66d <= $c && 0x66f >= $c) ||
                (0x671 <= $c && 0x6d5 >= $c) ||
                (0x6e5 <= $c && 0x6e6 >= $c) ||
                (0x6ee <= $c && 0x6ef >= $c) ||
                (0x6fa <= $c && 0x70d >= $c) ||
                0x710 === $c ||
                (0x712 <= $c && 0x72f >= $c) ||
                (0x74d <= $c && 0x7a5 >= $c) ||
                0x7b1 === $c ||
                (0x7c0 <= $c && 0x7ea >= $c) ||
                (0x7f4 <= $c && 0x7f5 >= $c) ||
                0x7fa === $c ||
                (0x800 <= $c && 0x815 >= $c) ||
                0x81a === $c ||
                0x824 === $c ||
                0x828 === $c ||
                (0x830 <= $c && 0x83e >= $c) ||
                (0x840 <= $c && 0x858 >= $c) ||
                0x85e === $c) {
                return static::RTL;
            }
        } elseif (0x200f === $c) {
            return static::RTL;
        } elseif (0xfb1d <= $c) {
            if (0xfb1d === $c ||
                (0xfb1f <= $c && 0xfb28 >= $c) ||
                (0xfb2a <= $c && 0xfb36 >= $c) ||
                (0xfb38 <= $c && 0xfb3c >= $c) ||
                0xfb3e === $c ||
                (0xfb40 <= $c && 0xfb41 >= $c) ||
                (0xfb43 <= $c && 0xfb44 >= $c) ||
                (0xfb46 <= $c && 0xfbc1 >= $c) ||
                (0xfbd3 <= $c && 0xfd3d >= $c) ||
                (0xfd50 <= $c && 0xfd8f >= $c) ||
                (0xfd92 <= $c && 0xfdc7 >= $c) ||
                (0xfdf0 <= $c && 0xfdfc >= $c) ||
                (0xfe70 <= $c && 0xfe74 >= $c) ||
                (0xfe76 <= $c && 0xfefc >= $c) ||
                (0x10800 <= $c && 0x10805 >= $c) ||
                0x10808 === $c ||
                (0x1080a <= $c && 0x10835 >= $c) ||
                (0x10837 <= $c && 0x10838 >= $c) ||
                0x1083c === $c ||
                (0x1083f <= $c && 0x10855 >= $c) ||
                (0x10857 <= $c && 0x1085f >= $c) ||
                (0x10900 <= $c && 0x1091b >= $c) ||
                (0x10920 <= $c && 0x10939 >= $c) ||
                0x1093f === $c ||
                0x10a00 === $c ||
                (0x10a10 <= $c && 0x10a13 >= $c) ||
                (0x10a15 <= $c && 0x10a17 >= $c) ||
                (0x10a19 <= $c && 0x10a33 >= $c) ||
                (0x10a40 <= $c && 0x10a47 >= $c) ||
                (0x10a50 <= $c && 0x10a58 >= $c) ||
                (0x10a60 <= $c && 0x10a7f >= $c) ||
                (0x10b00 <= $c && 0x10b35 >= $c) ||
                (0x10b40 <= $c && 0x10b55 >= $c) ||
                (0x10b58 <= $c && 0x10b72 >= $c) ||
                (0x10b78 <= $c && 0x10b7f >= $c)) {
                return static::RTL;
            }
        }

        return static::LTR;
    }
493567
public static function charCount($char): int
    {
        self::handleIncomingChar($char);
        $stringChar = (string) $char;

        return mb_ord($stringChar, mb_detect_encoding($stringChar)) > 0xFFFF ? 2 : 1;
    }
1102940
protected static boolean isNumeric(String s)
    {
        for (char c : s.toCharArray())
        {
            if (!Character.isDigit(c))
                return false;
        }
        return true;
    }
847615
public static function toDecimalCode(string $character) : int
    {
        $code = ord($character[0]);

        // Single byte / 0xxxxxxx
        if (!($code & 0x80)) {
            return $code;
        }

        $bytes = 1;

        // 2 bytes / 110xxxxx
        if (0xc0 === ($code & 0xe0)) {
            $code  = $code & ~0xc0;
            $bytes = 2;
        // 3 bytes / 1110xxxx
        } elseif (0xe0 === ($code & 0xf0)) {
            $code  = $code & ~0xe0;
            $bytes = 3;
        // 4 bytes / 11110xxx
        } elseif (0xf0 === ($code & 0xf8)) {
            $code  = $code & ~0xf0;
            $bytes = 4;
        }

        for ($i = 2; $i <= $bytes; $i++) {
            $code = ($code << 6) + (ord($character[$i - 1]) & ~0x80);
        }

        return $code;
    }
46328
public static function isGb2312($str)
    {
        for ($i = 0; $i < strlen($str); $i++) {
            $v = ord($str[$i]);
            if ($v > 127) {
                if (($v >= 228) && ($v <= 233)) {
                    if (($i + 2) >= (strlen($str) - 1)) return true;  // not enough characters
                    $v1 = ord($str[$i + 1]);
                    $v2 = ord($str[$i + 2]);
                    if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191))
                        return false;
                    else
                        return true;
                }
            }
        }
        return false;
    }
851802
private static boolean isNumeric(String value) {
    for (char c : value.toCharArray()) {
      if (!Character.isDigit(c)) {
        return false;
      }
    }
    return true;
  }
80419
protected int digit(int pos, int base) {
        char c = ch;
        if ('0' <= c && c <= '9')
            return Character.digit(c, base); //a fast common case
        int codePoint = peekSurrogates();
        int result = codePoint >= 0 ? Character.digit(codePoint, base) : Character.digit(c, base);
        if (result >= 0 && c > 0x7f) {
            log.error(pos + 1, "illegal.nonascii.digit");
            if (codePoint >= 0)
                scanChar();
            ch = "0123456789abcdef".charAt(result);
        }
        return result;
    }
622139
public static function randomChar( $char )
	{
		if ( strlen( $char ) == 0 )
			return '';

		$char = ord( $char );

		if ( $char > 64 && $char < 91 ) // Uppercase
			return static::randomCharRange( 65, 90 );

		if ( $char > 96 && $char < 123 ) // Lowercase
			return static::randomCharRange( 97, 122 );

		if ( $char > 47 && $char < 58 ) // Numeric
			return static::randomCharRange( 48, 57 );

		return static::$randomCharMap[random_int( 0, count( static::$randomCharMap ) )];
	}
954204
public function isValid()
    {
        return ((!empty($this->hex) && ctype_xdigit($this->hex)) && (!empty($this->dec) && ctype_digit($this->dec)));
    }