isascii

isascii(c::Union{Char,AbstractString}) -> Bool

Tests whether a character belongs to the ASCII character set, or whether this is true for all elements of a string.

Examples

  1. Check if a character is ASCII:

    julia> isascii('A')
    true
  2. Check if a string contains only ASCII characters:

    julia> isascii("Hello World!")
    true
  3. Handle non-ASCII characters:
    julia> isascii('๐ŸŒŸ')
    false

Common mistake example:

julia> isascii("ใ“ใ‚“ใซใกใฏ")
ERROR: MethodError: no method matching isascii(::String)

In this example, the isascii function is applied to a string containing non-ASCII characters. The isascii function only works with characters or strings containing ASCII characters, so make sure to check the input before using the function to avoid such errors.

See Also

BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: