Ejemplo n.º 1
0
        public override int NextCodePoint()
        {
            int c;

            for (; ;)
            {
                if (state == State.IterCheckFwd)
                {
                    c = iter.Next();
                    if (c < 0)
                    {
                        return(c);
                    }
                    if (CollationFCD.HasTccc(c))
                    {
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            CollationFCD.HasLccc(iter.Current))
                        {
                            iter.Previous();
                            if (!NextSegment())
                            {
                                return(Collation.SENTINEL_CP);
                            }
                            continue;
                        }
                    }
                    if (IsLeadSurrogate(c))
                    {
                        int trail = iter.Next();
                        if (IsTrailSurrogate(trail))
                        {
                            return(Character.ToCodePoint((char)c, (char)trail));
                        }
                        else if (trail >= 0)
                        {
                            iter.Previous();
                        }
                    }
                    return(c);
                }
                else if (state == State.IterInFCDSegment && pos != limit)
                {
                    c    = iter.NextCodePoint();
                    pos += Character.CharCount(c);
                    Debug.Assert(c >= 0);
                    return(c);
                }
                else if (state.CompareTo(State.InNormIterAtLimit) >= 0 &&
                         pos != normalized.Length)
                {
                    c    = normalized.CodePointAt(pos);
                    pos += Character.CharCount(c);
                    return(c);
                }
                else
                {
                    SwitchToForward();
                }
            }
        }
Ejemplo n.º 2
0
        protected override long HandleNextCE32()
        {
            int c;

            for (; ;)
            {
                if (state == State.IterCheckFwd)
                {
                    c = iter.Next();
                    if (c < 0)
                    {
                        return(NO_CP_AND_CE32);
                    }
                    if (CollationFCD.HasTccc(c))
                    {
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            CollationFCD.HasLccc(iter.Current))
                        {
                            iter.Previous();
                            if (!NextSegment())
                            {
                                c = Collation.SENTINEL_CP;
                                return(Collation.FALLBACK_CE32);
                            }
                            continue;
                        }
                    }
                    break;
                }
                else if (state == State.IterInFCDSegment && pos != limit)
                {
                    c = iter.Next();
                    ++pos;
                    Debug.Assert(c >= 0);
                    break;
                }
                else if (state.CompareTo(State.InNormIterAtLimit) >= 0 &&
                         pos != normalized.Length)
                {
                    c = normalized[pos++];
                    break;
                }
                else
                {
                    SwitchToForward();
                }
            }
            return(MakeCodePointAndCE32Pair(c, trie.GetFromU16SingleLead((char)c)));
        }
Ejemplo n.º 3
0
        public override int PreviousCodePoint()
        {
            char c;

            for (; ;)
            {
                if (checkDir < 0)
                {
                    if (pos == start)
                    {
                        return(Collation.SentinelCodePoint);
                    }
                    c = seq[--pos];
                    if (CollationFCD.HasLccc(c))
                    {
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            (pos != start && CollationFCD.HasTccc(seq[pos - 1])))
                        {
                            ++pos;
                            PreviousSegment();
                            c = seq[--pos];
                        }
                    }
                    break;
                }
                else if (checkDir == 0 && pos != start)
                {
                    c = seq[--pos];
                    break;
                }
                else
                {
                    SwitchToBackward();
                }
            }
            char lead;

            if (char.IsLowSurrogate(c) && pos != start &&
                char.IsHighSurrogate(lead = seq[pos - 1]))
            {
                --pos;
                return(Character.ToCodePoint(lead, c));
            }
            else
            {
                return(c);
            }
        }
Ejemplo n.º 4
0
        public override int NextCodePoint()
        {
            char c;

            for (; ;)
            {
                if (checkDir > 0)
                {
                    if (pos == limit)
                    {
                        return(Collation.SentinelCodePoint);
                    }
                    c = seq[pos++];
                    if (CollationFCD.HasTccc(c))
                    {
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            (pos != limit && CollationFCD.HasLccc(seq[pos])))
                        {
                            --pos;
                            NextSegment();
                            c = seq[pos++];
                        }
                    }
                    break;
                }
                else if (checkDir == 0 && pos != limit)
                {
                    c = seq[pos++];
                    break;
                }
                else
                {
                    SwitchToForward();
                }
            }
            char trail;

            if (char.IsHighSurrogate(c) && pos != limit &&
                char.IsLowSurrogate(trail = seq[pos]))
            {
                ++pos;
                return(Character.ToCodePoint(c, trail));
            }
            else
            {
                return(c);
            }
        }
Ejemplo n.º 5
0
        protected override long HandleNextCE32()
        {
            char c;

            for (; ;)
            {
                if (checkDir > 0)
                {
                    if (pos == limit)
                    {
                        return(NoCodePointAndCE32);
                    }
                    c = seq[pos++];
                    if (CollationFCD.HasTccc(c))
                    {
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            (pos != limit && CollationFCD.HasLccc(seq[pos])))
                        {
                            --pos;
                            NextSegment();
                            c = seq[pos++];
                        }
                    }
                    break;
                }
                else if (checkDir == 0 && pos != limit)
                {
                    c = seq[pos++];
                    break;
                }
                else
                {
                    SwitchToForward();
                }
            }
            return(MakeCodePointAndCE32Pair(c, trie.GetFromU16SingleLead(c)));
        }
Ejemplo n.º 6
0
        public override int PreviousCodePoint()
        {
            int c;

            for (; ;)
            {
                if (state == State.IterCheckBwd)
                {
                    c = iter.Previous();
                    if (c < 0)
                    {
                        start = pos = 0;
                        state = State.IterInFCDSegment;
                        return(Collation.SENTINEL_CP);
                    }
                    if (CollationFCD.HasLccc(c))
                    {
                        int prev = Collation.SENTINEL_CP;
                        if (CollationFCD.MaybeTibetanCompositeVowel(c) ||
                            CollationFCD.HasTccc(prev = iter.Previous()))
                        {
                            iter.Next();
                            if (prev >= 0)
                            {
                                iter.Next();
                            }
                            if (!PreviousSegment())
                            {
                                return(Collation.SENTINEL_CP);
                            }
                            continue;
                        }
                        // hasLccc(trail)=true for all trail surrogates
                        if (IsTrailSurrogate(c))
                        {
                            if (prev < 0)
                            {
                                prev = iter.Previous();
                            }
                            if (IsLeadSurrogate(prev))
                            {
                                return(Character.ToCodePoint((char)prev, (char)c));
                            }
                        }
                        if (prev >= 0)
                        {
                            iter.Next();
                        }
                    }
                    return(c);
                }
                else if (state == State.IterInFCDSegment && pos != start)
                {
                    c    = iter.PreviousCodePoint();
                    pos -= Character.CharCount(c);
                    Debug.Assert(c >= 0);
                    return(c);
                }
                else if (state.CompareTo(State.InNormIterAtLimit) >= 0 && pos != 0)
                {
                    c    = normalized.CodePointBefore(pos);
                    pos -= Character.CharCount(c);
                    return(c);
                }
                else
                {
                    SwitchToBackward();
                }
            }
        }