CanReplaceAt() private method

private CanReplaceAt ( int index ) : bool
index int
return bool
Esempio n. 1
0
            public override bool Fallback(char charUnknown, int index)
            {
                // If we are already in fallback, throw, it's probably at the suspect character in charEntity
                if (_charEntityIndex >= 0)
                {
                    (new EncoderExceptionFallback()).CreateFallbackBuffer().Fallback(charUnknown, index);
                }

                // find out if we can replace the character with entity
                if (_parent.CanReplaceAt(index))
                {
                    // Create the replacement character entity
                    _charEntity      = string.Create(null, stackalloc char[64], $"&#x{(int)charUnknown:X};");
                    _charEntityIndex = 0;
                    return(true);
                }

                EncoderFallbackBuffer errorFallbackBuffer = (new EncoderExceptionFallback()).CreateFallbackBuffer();

                errorFallbackBuffer.Fallback(charUnknown, index);
                return(false);
            }
        public override bool Fallback(char charUnknown, int index)
        {
            // If we are already in fallback, throw, it's probably at the suspect character in charEntity
            if (_charEntityIndex >= 0)
            {
                (new EncoderExceptionFallback()).CreateFallbackBuffer().Fallback(charUnknown, index);
            }

            // find out if we can replace the character with entity
            if (_parent.CanReplaceAt(index))
            {
                // Create the replacement character entity
                _charEntity      = string.Format(CultureInfo.InvariantCulture, "&#x{0:X};", new object[] { (int)charUnknown });
                _charEntityIndex = 0;
                return(true);
            }
            else
            {
                EncoderFallbackBuffer errorFallbackBuffer = (new EncoderExceptionFallback()).CreateFallbackBuffer();
                errorFallbackBuffer.Fallback(charUnknown, index);
                return(false);
            }
        }