Esempio n. 1
0
        private static EastAsianWidthRange ParseRange(string line)
        {
            var values        = line.Substring(0, line.IndexOf('#')).Trim().Split(";".ToCharArray());
            var rangeSegments = values[0].Trim();
            var kindSegment   = values[1].Trim();

            EastAsianWidthKind kind = kindSegment switch
            {
                "A" => EastAsianWidthKind.Ambiguous,
                "F" => EastAsianWidthKind.FullWidth,
                "H" => EastAsianWidthKind.HalfWidth,
                "Na" => EastAsianWidthKind.Narrow,
                "W" => EastAsianWidthKind.Wide,
                "N" => EastAsianWidthKind.Neutral,
                _ => throw new NotSupportedException($"Not supported kind:{kindSegment}")
            };

            var index = rangeSegments.IndexOf("..", StringComparison.Ordinal);

            int start;
            int end;

            if (index < 0)
            {
                start = Convert.ToInt32(rangeSegments, 16);
                end   = start;
            }
            else
            {
                start = Convert.ToInt32(rangeSegments.Substring(0, index), 16);
                end   = Convert.ToInt32(rangeSegments.Substring(index + 2, rangeSegments.Length - index - 2), 16);
            }

            return(new EastAsianWidthRange(start, end, kind));
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Resolve instance.
 /// </summary>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="kind"></param>
 public EastAsianWidthRange(int start, int end, EastAsianWidthKind kind)
 {
     Start = start;
     End   = end;
     Kind  = kind;
 }