ASN1UTF8String.fromBytes constructor

ASN1UTF8String.fromBytes(
  1. Uint8List encodedBytes
)

Creates an ASN1UTF8String entity from the given encodedBytes.

Implementation

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