toBinarySync method

Uint8List toBinarySync(
  1. String s
)

Implementation

Uint8List toBinarySync(String s) {
  List<int> elements = [];
  int? buffer;
  var codeUnits = s.codeUnits;
  for (var codeUnit in codeUnits) {
    var c = String.fromCharCode(codeUnit);
    var indexOf = dict.indexOf(c);
    if (buffer == null) {
      buffer = indexOf << 4;
    } else {
      buffer = buffer + indexOf;
      elements.add(buffer);
      buffer = null;
    }
  }
  return Uint8List.fromList(elements);
}