write method

void write(
  1. String text
)

Writes data to the _terminal. Terminal sequences or special characters are not interpreted and directly added to the buffer.

See also: Terminal.write

Implementation

void write(String text) {
  final units = text.codeUnits;
  for (var i = 0; i < units.length; i++) {
    final unit = units[i];
    // Combine UTF-16 surrogate pairs into a single Unicode code point.
    if (unit >= 0xD800 && unit <= 0xDBFF && i + 1 < units.length) {
      final low = units[i + 1];
      if (low >= 0xDC00 && low <= 0xDFFF) {
        final codePoint = 0x10000 + ((unit & 0x3FF) << 10) + (low & 0x3FF);
        writeChar(codePoint);
        i++;
        continue;
      }
    }
    writeChar(unit);
  }
}