コード例 #1
0
        /// <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]);
        }
コード例 #2
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);
        }