tguard-js
    Preparing search index...

    Function isASCIIString

    • Determines whether the provided value is a string containing only ASCII characters.

      Parameters

      • x: unknown

        The value to validate.

      Returns x is string

      true if the value is a string containing only ASCII characters.

      This function validates that all characters in the string fall within the ASCII range (0x00 to 0x7F), including control characters.

      This includes:

      • printable characters (A-Z, a-z, 0-9, punctuation)
      • control characters (\n, \r, \t, etc.)
      • null character (\0)

      Valid ASCII strings:

      isASCIIString('hello'); // true
      isASCIIString('hello\n'); // true
      isASCIIString(''); // true

      Invalid non-ASCII strings:

      isASCIIString('こんにちは'); // false
      isASCIIString('café'); // false
      isASCIIString(''); // false

      1.1