writeString method

void writeString(
  1. String string
)

Writes ASCII string to the sink, replacing any non-ASCII characters with whitespace.

Implementation

void writeString(String string) {
  intAtIndex(int index) {
    var c = string.codeUnitAt(index);
    if (isValidAsciiChar(c)) {
      return c;
    } else {
      return 32;
    }
  }

  writeBytes(List<int>.generate(string.length, intAtIndex));
}