Documentation

Init.Data.String.Extra

@[reducible, inline, deprecated ByteArray.utf8DecodeChar? (since := "2025-10-01")]
Equations
Instances For
    @[reducible, inline, deprecated ByteArray.validateUTF8 (since := "2025-10-01")]

    Checks whether an array of bytes is a valid UTF-8 encoding of a string.

    Equations
    Instances For

      Consistently de-indents the lines in a string, removing the same amount of leading whitespace from each line such that the least-indented line has no leading whitespace.

      The number of leading whitespace characters to remove from each line is determined by counting the number of leading space (' ') and tab ('\t') characters on lines after the first line that also contain non-whitespace characters. No distinction is made between tab and space characters; both count equally.

      The least number of leading whitespace characters found is then removed from the beginning of each line. The first line's leading whitespace is not counted when determining how far to de-indent the string, but leading whitespace is removed from it.

      Examples:

      Equations
      Instances For

        Replaces each \r\n with \n to normalize line endings, but does not validate that there are no isolated \r characters.

        This is an optimized version of String.replace text "\r\n" "\n".

        Equations
        Instances For