isvalid(str, i)

Tells whether index i is valid for the given string


  1. Check if a character is valid:

    julia> isvalid('a')
  2. Check if a string is valid ASCII:

    julia> isvalid("hello")
  3. Check if a string is valid UTF-8:

    julia> isvalid("こんにちは")
  4. Check if a string is valid UTF-16:

    julia> isvalid("🌍")
  5. Check if a string is valid UTF-32:
    julia> isvalid("🚀")

Common mistake example:

julia> isvalid("你好")

The isvalid function only checks the validity of the given value for specific types (Char, ASCIIString, UTF8String, UTF16String, or UTF32String). It does not perform a comprehensive validity check for all possible strings. In this example, "你好" is a valid UTF-8 string, but the function returns true because it only checks for specific types.

See Also

ascii, base64decode, Base64DecodePipe, base64encode, Base64EncodePipe, bin, bits, bytestring, charwidth, chomp, chop, chr2ind, contains, endswith, escape_string, graphemes, ind2chr, iscntrl, istext, isupper, isvalid, join, lcfirst, lowercase, lpad, lstrip, normalize_string, num2hex, parseip, randstring, readuntil, replace, repr, rpad, rsplit, rstrip, search, searchindex, split, startswith, string, stringmime, strip, strwidth, summary, takebuf_string, ucfirst, unescape_string, uppercase, utf16, utf32, utf8, wstring,

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: