public override void Encode(Asn1BerOutputStream outs, bool explicitTagging) { try { var bytes = Encoding.UTF8.GetBytes(Value); if (explicitTagging) { outs.EncodeTag(Tag); } outs.EncodeLength(bytes.Length); outs.Write(bytes); } catch (IOException exception) { Console.Out.WriteLine("This JVM does not support UTF-8 encoding"); Asn1Util.WriteStackTrace(exception, Console.Error); } }
public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging) { var len = 0; try { var bytes = Encoding.UTF8.GetBytes(Value); len = bytes.Length; buffer.Copy(bytes); } catch (IOException exception) { Console.Out.WriteLine("This JVM does not support UTF-8 encoding"); Asn1Util.WriteStackTrace(exception, Console.Error); } if (explicitTagging) { len += buffer.EncodeTagAndLength(Tag, len); } return(len); }