Ejemplo n.º 1
0
        public override int Read()
        {
            while (true)
            {
                if (replacement != null && charPointer < replacement.Length)
                {
                    return(replacement[charPointer++]);
                }

                int firstChar = NextChar();
                if (firstChar == -1)
                {
                    return(-1);
                }
                NormalizeCharMap nm = normMap.submap != null?(NormalizeCharMap)normMap.submap[CharacterCache.ValueOf((char)firstChar)]:null;
                if (nm == null)
                {
                    return(firstChar);
                }
                NormalizeCharMap result = Match(nm);
                if (result == null)
                {
                    return(firstChar);
                }
                replacement = result.normStr;
                charPointer = 0;
                if (result.diff != 0)
                {
                    int prevCumulativeDiff = GetLastCumulativeDiff();
                    if (result.diff < 0)
                    {
                        for (int i = 0; i < -result.diff; i++)
                        {
                            AddOffCorrectMap(nextCharCounter + i - prevCumulativeDiff, prevCumulativeDiff - 1 - i);
                        }
                    }
                    else
                    {
                        AddOffCorrectMap(nextCharCounter - result.diff - prevCumulativeDiff, prevCumulativeDiff + result.diff);
                    }
                }
            }
        }