public static string DecodeUtf8String(IBerInput input, int length) { var intLength = (int)length; var bytes = ReadString(input, ref intLength); return Encoding.UTF8.GetString(bytes, 0, intLength); }
/// <summary> /// Decodes the value of the current TLV an UTF-8 string. /// Throws an exception in case of a format mismatch. /// </summary> /// <returns>The string value of the current TLV.</returns> public string GetString() { if (IsContainer) { ThrowError(205, "Invalid String encoding"); } Debug.Assert(Value != null || Length == 0); Debug.Assert(Type == BerType.UTF8String || Type == BerType.Bitstring || BerType.IsApplicationDefined(Type)); var input = new BerMemoryInput(Value); return(BerEncoding.DecodeUtf8String(input, Length)); }