LineSeparator

A representation of line endings, that can be used throughout the codebase. This is to replace Utils.EOL which is not explicit in representing the system's EOL character. It also exposes helper methods for, e.g., detection of the line ending of a given string.

Author

Roger Howell

See also

Entries

Link copied to clipboard

The CR \r line ending is the default line separator for classic MacOS

Link copied to clipboard

The LF \n line ending is the default line separator for Unix and modern MacOS

Link copied to clipboard

The CRLF \r\n line ending is the default line separator for Windows

Link copied to clipboard

This line ending is set to whatever the host system's line separator is

Link copied to clipboard

The ARBITRARY line ending can be used where we do not care about the line separator, only that we use the same one consistently

Link copied to clipboard

The MIXED line ending is used where strings appear to have multiple different line separators e.g. "line 1\nline 2\rline 3\r\n" or "line 1\nline 2\rline 3\nline 4\n"

Link copied to clipboard

The UNKNOWN line ending can be used in the case where the given string has not yet been analysed to determine its line separator

Link copied to clipboard

The NONE line ending is used where there are precisely zero line endings e.g. a simple one-line string

Functions

Link copied to clipboard
Link copied to clipboard
open fun asRawString(): String
Link copied to clipboard
open fun describe(): String
Link copied to clipboard
open fun detect(string: String): LineSeparator
Link copied to clipboard
open fun equalsString(lineSeparator: LineSeparator): Boolean
Link copied to clipboard
open fun getLineEnding(countCr: Int, countLf: Int, countCrLf: Int): LineSeparator
Link copied to clipboard
Link copied to clipboard
open fun lookup(ending: String): Optional<LineSeparator>
Link copied to clipboard
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun valueOf(name: String): LineSeparator

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.