EncoderContext constructor

EncoderContext(
  1. String msg
)

Implementation

EncoderContext(String msg) {
  //From this point on Strings are not Unicode anymore!
  final msgBinary = latin1.encode(msg);
  final sb = StringBuffer();
  final c = msgBinary.length;
  for (int i = 0; i < c; i++) {
    final ch = msgBinary[i];
    if (ch == 63 /*'?'*/ && msg[i] != '?') {
      throw ArgumentError(
        'Message contains characters outside ISO-8859-1 encoding.',
      );
    }
    sb.writeCharCode(ch);
  }
  _msg = sb.toString(); //Not Unicode here!
  _shape = SymbolShapeHint.forceNone;
  _codewords = StringBuffer();
  _newEncoding = -1;
}