isprint
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.
Examples
-
Check if a character is printable:
julia> isprint('A') true
-
Check if a character is a control character:
julia> isprint('\n') false
-
Check if a string contains only printable characters:
julia> isprint("Hello World") true
-
Check if a string contains control characters:
julia> isprint("Hello\nWorld") false
- Check if a string contains non-printable characters:
julia> isprint("Hello\x01World") false
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.