System.Text.EncoderReplacementFallbackBuffer.Fallback C# (CSharp) Method

Fallback() public method

public Fallback ( char charUnknown, int index ) : bool
charUnknown char
index int
return bool
        public override bool Fallback(char charUnknown, int index)
        {
            // If we had a buffer already we're being recursive, throw, it's probably at the suspect
            // character in our array.
            if (fallbackCount >= 1)
            {
                // If we're recursive we may still have something in our buffer that makes this a surrogate
                if (char.IsHighSurrogate(charUnknown) && fallbackCount >= 0 &&
                    char.IsLowSurrogate(strDefault[fallbackIndex+1]))
                    ThrowLastCharRecursive(Char.ConvertToUtf32(charUnknown, strDefault[fallbackIndex+1]));

                // Nope, just one character
                ThrowLastCharRecursive(unchecked((int)charUnknown));
            }

            // Go ahead and get our fallback
            // Divide by 2 because we aren't a surrogate pair
            fallbackCount = strDefault.Length/2;
            fallbackIndex = -1;

            return fallbackCount != 0;
        }

Same methods

EncoderReplacementFallbackBuffer::Fallback ( char charUnknownHigh, char charUnknownLow, int index ) : bool

Usage Example

Beispiel #1
0
        public void FallbackRecursiveError()
        {
            Buffer b = NewInstance();

            b.Fallback('X', 0);
            b.Fallback('X', 0);
        }
All Usage Examples Of System.Text.EncoderReplacementFallbackBuffer::Fallback