System.Text.Decoder.Convert C# (CSharp) Method

Convert() private method

private Convert ( byte bytes, int byteCount, char chars, int charCount, bool flush, int &bytesUsed, int &charsUsed, bool &completed ) : void
bytes byte
byteCount int
chars char
charCount int
flush bool
bytesUsed int
charsUsed int
completed bool
return void
        public virtual unsafe void Convert(byte* bytes, int byteCount,
                                             char* chars, int charCount, bool flush,
                                             out int bytesUsed, out int charsUsed, out bool completed)
        {
            // Validate input parameters
            if (chars == null || bytes == null)
                throw new ArgumentNullException(chars == null ? "chars" : "bytes",
                    Environment.GetResourceString("ArgumentNull_Array"));

            if (byteCount < 0 || charCount < 0)
                throw new ArgumentOutOfRangeException((byteCount<0 ? "byteCount" : "charCount"),
                    Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));

            // Get ready to do it
            bytesUsed = byteCount;

            // Its easy to do if it won't overrun our buffer.
            while (bytesUsed > 0)
            {
                if (GetCharCount(bytes, bytesUsed, flush) <= charCount)
                {
                    charsUsed = GetChars(bytes, bytesUsed, chars, charCount, flush);
                    completed = (bytesUsed == byteCount &&
                        (m_fallbackBuffer == null || m_fallbackBuffer.Remaining == 0));
                    return;
                }

                // Try again with 1/2 the count, won't flush then 'cause won't read it all
                flush = false;
                bytesUsed /= 2;
            }

            // Oops, we didn't have anything, we'll have to throw an overflow
            throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow"));
        }
    }

Same methods

Decoder::Convert ( byte bytes, int byteIndex, int byteCount, char chars, int charIndex, int charCount, bool flush, int &bytesUsed, int &charsUsed, bool &completed ) : void

Usage Example

示例#1
0
        public static void Convert(this System.Text.Decoder decoder, Collections.Buffer <byte> bytes, Collections.Buffer <char> charBuffer)
        {
            int  bytesUsed;
            int  charsUsed;
            bool completed;

            decoder.Convert(bytes, charBuffer, out bytesUsed, out charsUsed, out completed);
        }
All Usage Examples Of System.Text.Decoder::Convert