ascii method

void ascii(
  1. String data
)

Add ASCII-encoded Text data

Implementation

void ascii(String data) {
  final input = data.codeUnits;

  for (var i = 0; i < input.length;) {
    final c = input[i];
    i++;

    if (c >= 0x30 &&
        c <= 0x39 &&
        i < input.length &&
        input[i] >= 0x30 &&
        input[i] <= 0x39) {
      // two numbers...
      final c2 = input[i];
      i++;
      final cw = ((c - 0x30) * 10 + (c2 - 0x30)) + 0x82;
      _data.addByte(cw);
    } else if (c > 0x7f) {
      // not correct... needs to be redone later...
      _data.addByte(0xeb);
      _data.addByte(c - 0x7f);
    } else {
      _data.addByte(c + 1);
    }
  }
}