System.Text.GB18030Encoding.GetMaxCharCount C# (CSharp) Method

GetMaxCharCount() public method

public GetMaxCharCount ( int byteCount ) : int
byteCount int
return int
        public override int GetMaxCharCount(int byteCount)
        {
            if (byteCount < 0)
                throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum);
            Contract.EndContractBlock();

            // Just return length, we could have a single char for each byte + whatever extra our decoder could do to us.
            // If decoder is messed up it could spit out 3 ?s.
            long charCount = ((long)byteCount) + 3;

            // Take fallback size into consideration
            if (DecoderFallback.MaxCharCount > 1)
                charCount *= DecoderFallback.MaxCharCount;

            if (charCount > 0x7fffffff)
                throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow);

            return (int)charCount;
        }