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

Reset() private method

private Reset ( ) : void
return void
        public virtual void Reset()
        {
            byte[] byteTemp = {};
            char[] charTemp = new char[GetCharCount(byteTemp, 0, 0, true)];
            GetChars(byteTemp, 0, 0, charTemp, 0, true);
            if (m_fallbackBuffer != null)
                m_fallbackBuffer.Reset();
        }

Usage Example

示例#1
0
        public string ReadExisting()
        {
            if (!this.IsOpen)
            {
                throw new InvalidOperationException(SR.GetString("Port_not_open"));
            }
            byte[] dst = new byte[this.BytesToRead];
            if (this.readPos < this.readLen)
            {
                Buffer.BlockCopy(this.inBuffer, this.readPos, dst, 0, this.CachedBytesToRead);
            }
            this.internalSerialStream.Read(dst, this.CachedBytesToRead, dst.Length - this.CachedBytesToRead);
            System.Text.Decoder decoder = this.Encoding.GetDecoder();
            int num    = decoder.GetCharCount(dst, 0, dst.Length);
            int length = dst.Length;

            if (num == 0)
            {
                Buffer.BlockCopy(dst, 0, this.inBuffer, 0, dst.Length);
                this.readPos = 0;
                this.readLen = dst.Length;
                return("");
            }
            do
            {
                decoder.Reset();
                length--;
            }while (decoder.GetCharCount(dst, 0, length) == num);
            this.readPos = 0;
            this.readLen = dst.Length - (length + 1);
            Buffer.BlockCopy(dst, length + 1, this.inBuffer, 0, dst.Length - (length + 1));
            return(this.Encoding.GetString(dst, 0, length + 1));
        }
All Usage Examples Of System.Text.Decoder::Reset