private LineBreakClass MapClass(CodePoint cp, LineBreakClass c)
        {
            // LB 1
            // ==========================================
            // Resolved Original    General_Category
            // ==========================================
            // AL       AI, SG, XX  Any
            // CM       SA          Only Mn or Mc
            // AL       SA          Any except Mn and Mc
            // NS       CJ          Any
            switch (c)
            {
            case LineBreakClass.AI:
            case LineBreakClass.SG:
            case LineBreakClass.XX:
                return(LineBreakClass.AL);

            case LineBreakClass.SA:
                UnicodeCategory category = CodePoint.GetGeneralCategory(cp);
                return((category is UnicodeCategory.NonSpacingMark or UnicodeCategory.SpacingCombiningMark)
                        ? LineBreakClass.CM
                        : LineBreakClass.AL);

            case LineBreakClass.CJ:
                return(LineBreakClass.NS);

            default:
                return(c);
            }
        }
            public void MoveNext()
            {
                this.CharsConsumed += this.charsConsumed;
                var codePoint = CodePoint.DecodeFromUtf16At(this.source, this.CharsConsumed, out this.charsConsumed);

                this.CurrentType = CodePoint.GetGraphemeClusterClass(codePoint);
            }
        private static JoiningType GetJoiningType(CodePoint codePoint, uint value, UnicodeCategory category)
        {
            var type = (JoiningType)(value & 0xFF);

            // All others not explicitly listed have joining type U
            if (type == JoiningType.NonJoining)
            {
                // 200C; ZERO WIDTH NON-JOINER; U; No_Joining_Group
                // 200D; ZERO WIDTH JOINER; C; No_Joining_Group
                // 202F; NARROW NO-BREAK SPACE; U; No_Joining_Group
                // 2066; LEFT-TO-RIGHT ISOLATE; U; No_Joining_Group
                // 2067; RIGHT-TO-LEFT ISOLATE; U; No_Joining_Group
                // 2068; FIRST STRONG ISOLATE; U; No_Joining_Group
                // 2069; POP DIRECTIONAL ISOLATE; U; No_Joining_Group
                if (codePoint.Value is 0x200C
                    or 0x200D
                    or 0x202F
                    or 0x2066
                    or 0x2067
                    or 0x2068
                    or 0x2069)
                {
                    return(type);
                }

                // Those that are not explicitly listed and that are of General Category Mn, Me, or Cf have joining type T.
                if (category is UnicodeCategory.NonSpacingMark or UnicodeCategory.EnclosingMark or UnicodeCategory.Format)
                {
                    type = JoiningType.Transparent;
                }
            }

            return(type);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JoiningClass"/> struct.
        /// </summary>
        /// <param name="codePoint">The codepoint.</param>
        public JoiningClass(CodePoint codePoint)
        {
            UnicodeCategory category = CodePoint.GetGeneralCategory(codePoint);
            uint            value    = UnicodeData.GetJoiningClass(codePoint.Value);

            this.JoiningType  = GetJoiningType(codePoint, value, category);
            this.JoiningGroup = (JoiningGroup)((value >> 16) & 0xFF);
        }
 public LineBreakEnumerator(ReadOnlySpan <char> source)
     : this()
 {
     this.source            = source;
     this.pointsLength      = CodePoint.GetCodePointCount(source);
     this.charPosition      = 0;
     this.position          = 0;
     this.lastPosition      = 0;
     this.currentClass      = LineBreakClass.XX;
     this.nextClass         = LineBreakClass.XX;
     this.first             = true;
     this.lb8a              = false;
     this.lb21a             = false;
     this.lb22ex            = false;
     this.lb24ex            = false;
     this.lb25ex            = false;
     this.alphaNumericCount = 0;
     this.lb31              = false;
     this.lb30              = false;
     this.lb30a             = 0;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BidiClass"/> struct.
 /// </summary>
 /// <param name="codePoint">The codepoint.</param>
 public BidiClass(CodePoint codePoint)
 => this.bidiValue = UnicodeData.GetBidiData(codePoint.Value);
Exemplo n.º 7
0
 /// <summary>
 /// Advances the enumerator to the next element of the collection.
 /// </summary>
 /// <returns>
 /// <see langword="true"/> if the enumerator was successfully advanced to the next element;
 /// <see langword="false"/> if the enumerator has passed the end of the collection.
 /// </returns>
 public bool MoveNext()
 {
     this.Current = CodePoint.DecodeFromUtf16At(this.source, 0, out int consumed);
     this.source  = this.source.Slice(consumed);
     return(consumed > 0);
 }