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

Tests whether a character is printable, including spaces, but not a control character. For strings, tests whether this is true for all elements of the string.


  1. Check if a character is printable:

    julia> isprint('A')
  2. Check if a character is a control character:

    julia> isprint('\n')
  3. Check if a string contains only printable characters:

    julia> isprint("Hello World")
  4. Check if a string contains control characters:

    julia> isprint("Hello\nWorld")
  5. Check if a string contains non-printable characters:
    julia> isprint("Hello\x01World")

Common mistake example:

julia> isprint(65)
ERROR: MethodError: no method matching isprint(::Int64)

In this example, the input provided is not a character or string type. The isprint function expects either a Char or AbstractString as input. Make sure to pass a valid character or string to the function to avoid such errors.

See Also

:@printf, :@sprintf, display, displayable, dump, info, isprint, print, println, print_escaped, print_joined, print_shortest, print_unescaped, print_with_color, pushdisplay, redisplay, show, showall, showcompact, sprint, versioninfo,

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

Checking you are not a robot: