Reset() публичный Метод

public Reset ( ) : void
Результат void
Пример #1
0
 // Reset the Decoder
 //
 // Normally if we call GetChars() and an error is thrown we don't change the state of the Decoder.  This
 // would allow the caller to correct the error condition and try again (such as if they need a bigger buffer.)
 //
 // If the caller doesn't want to try again after GetChars() throws an error, then they need to call Reset().
 //
 // Virtual implementation has to call GetChars with flush and a big enough buffer to clear a 0 byte string
 // We avoid GetMaxCharCount() because a) we can't call the base encoder and b) it might be really big.
 public virtual void Reset()
 {
     byte[] byteTemp = Array.Empty <byte>();
     char[] charTemp = new char[GetCharCount(byteTemp, 0, 0, true)];
     GetChars(byteTemp, 0, 0, charTemp, 0, true);
     _fallbackBuffer?.Reset();
 }
Пример #2
0
 public virtual void Reset()
 {
     if (fallback_buffer != null)
     {
         fallback_buffer.Reset();
     }
 }
Пример #3
0
 public override void Reset()
 {
     if (m_fallbackBuffer != null)
     {
         m_fallbackBuffer.Reset();
     }
 }
Пример #4
0
 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();
     }
 }
 internal unsafe void InternalReset()
 {
     byteStart = null;
     _fallbackBuffer.Reset();
 }
	// for GetChars()
	static unsafe void Fallback (object provider, ref DecoderFallbackBuffer buffer, ref byte [] bufferArg, byte* bytes, long byteIndex, uint size,
		char* chars, ref int charIndex)
	{
		if (buffer == null) {
			DecoderFallback fb = provider as DecoderFallback;
			if (fb != null)
				buffer = fb.CreateFallbackBuffer ();
			else
				buffer = ((Decoder) provider).FallbackBuffer;
		}
		if (bufferArg == null)
			bufferArg = new byte [1];
		for (int i = 0; i < size; i++) {
			bufferArg [0] = bytes [byteIndex + i];
			buffer.Fallback (bufferArg, 0);
			while (buffer.Remaining > 0)
				chars [charIndex++] = buffer.GetNextChar ();
			buffer.Reset ();
		}
	}
	// for GetCharCount()
	static unsafe int Fallback (object provider, ref DecoderFallbackBuffer buffer, ref byte [] bufferArg, byte* bytes, long index, uint size)
	{
		if (buffer == null) {
			DecoderFallback fb = provider as DecoderFallback;
			if (fb != null)
				buffer = fb.CreateFallbackBuffer ();
			else
				buffer = ((Decoder) provider).FallbackBuffer;
		}
		if (bufferArg == null)
			bufferArg = new byte [1];
		int ret = 0;
		for (int i = 0; i < size; i++) {
			bufferArg [0] = bytes [(int) index + i];
			buffer.Fallback (bufferArg, 0);
			ret += buffer.Remaining;
			buffer.Reset ();
		}
		return ret;
	}
Пример #8
0
 public override void Reset()
 {
     m_fallbackBuffer?.Reset();
 }
Пример #9
0
	// This function is called when we want to flush the decoder state
	// (i.e. in case of invalid UTF-8 characters or interrupted sequences)
	internal unsafe static DecoderStatus InternalGetCharsFlush (
		char* chars, int charCount,
		DecoderFallbackBuffer fallbackBuffer,
		DecoderStatus s,
		int bytesProcessed, ref int charsProcessed,
		ref uint leftBytes, ref uint leftBits, ref uint procBytes)
	{
		// if there is nothing to flush, then exit silently
		if(procBytes == 0)
			return DecoderStatus.Ok;
		// now we build a 'bytesUnknown' array with the
		// stored bytes in 'procBytes'.
		int extra = 0;
		for (uint t = procBytes; t != 0; extra++)
			t = t >> 8;
		byte [] bytesUnknown = new byte [extra];
		for (int i = extra; i > 0; i--)
			bytesUnknown [i - 1] = (byte) ((procBytes >> (8 * (extra - i))) & 0xff);
		// partial reset: this condition avoids infinite loops
		if (s == DecoderStatus.InvalidSequence)
			leftBytes = 0;
		// call the fallback and cross fingers
		fallbackBuffer.Fallback (bytesUnknown, bytesProcessed - extra);
		if (chars != null) {
			while (fallbackBuffer.Remaining > 0) {
				if (charsProcessed >= charCount)
					return DecoderStatus.InsufficientSpace;
				chars [charsProcessed++] = fallbackBuffer.GetNextChar ();
			}
		} else
			charsProcessed += fallbackBuffer.Remaining;
		fallbackBuffer.Reset ();

		// recovery was succesful, flush decoder state
		leftBits = leftBytes = procBytes = 0;

		return DecoderStatus.Ok;
	}