ASN1TeletextString.fromBytes constructor

ASN1TeletextString.fromBytes(
  1. Uint8List encodedBytes
)

Creates an ASN1TeletextString entity from the given encodedBytes.

Implementation

ASN1TeletextString.fromBytes(Uint8List encodedBytes)
    : super.fromBytes(encodedBytes) {
  if (ASN1Utils.isConstructed(encodedBytes.elementAt(0))) {
    elements = [];
    var parser = ASN1Parser(valueBytes);
    var sb = StringBuffer();
    while (parser.hasNext()) {
      var printableString = parser.nextObject() as ASN1TeletextString;
      sb.write(printableString.stringValue);
      elements!.add(printableString);
    }
    stringValue = sb.toString();
  } else {
    stringValue = ascii.decode(valueBytes!);
  }
}