/// <summary> /// Return the encoding byte order mark. /// </summary> /// <param name="encoding">The encoding to be checked.</param> /// <returns>The encoding byte order mark.</returns> public static byte[] GetByteOrderMark(this EncodingType encoding) { var attribute = encoding.GetAttribute <ByteOrderMarkAttribute>(); return(attribute?.ByteOrderMark ?? new byte[0]); }
/// <summary> /// Return the number of byters per unit for the encoding. /// </summary> /// <param name="encoding">The encoding to be checked.</param> /// <returns>The number of bytes per unit</returns> public static int GetNumBytesPerUnit(this EncodingType encoding) { var attribute = encoding.GetAttribute <NumBytesPerUnitAttribute>(); return(attribute?.NumBytesPerUnit ?? 0); }