isLineTerminator static method

bool isLineTerminator(
  1. int codeUnit
)

Check if the given code unit is a line terminator character.

Includes newline characters from ASCII (https://www.unicode.org/standard/reports/tr13/tr13-5.html).

Implementation

static bool isLineTerminator(int codeUnit) {
  switch (codeUnit) {
    case 0x0A: // line feed
    case 0x0B: // vertical feed
    case 0x0C: // form feed
    case 0x0D: // carriage return
    case 0x85: // new line
    case 0x2028: // line separator
    case 0x2029: // paragraph separator
      return true;
    default:
      return false;
  }
}