Example #1
0
        /// <summary>
        /// Create a UnicodeRange instance, using the provided UnicodeChart Enum type.
        /// </summary>
        /// <param name="chart">Group name of scripts, symbols or punctuations (e.g. "European Scripts", "Punctuation", etc.)</param>
        public UnicodeRange(UnicodeChart chart)
        {
            UnicodeRange range = RangePropertyCollector.GetUnicodeChartRange(new UnicodeRangeDatabase(), chart);

            startOfUnicodeRange = range.StartOfUnicodeRange;
            endOfUnicodeRange   = range.EndOfUnicodeRange;
        }
Example #2
0
 /// <summary>
 /// Define LineBreakDatabase class,
 /// <a href="http://www.unicode.org/charts/">Newline</a>
 /// </summary>
 public SubGroup(UnicodeRange range, string name, string ids, UnicodeChart chart)
 {
     UnicodeRange = new UnicodeRange(range);
     SubGroupName = name;
     SubIds       = ids;
     UnicodeChart = chart;
 }
 public Group(UnicodeRange range, string groupName, string name, string ids, UnicodeChart chart)
 {
     UnicodeRange = new UnicodeRange(range);
     GroupName    = groupName;
     Name         = name;
     Ids          = ids;
     UnicodeChart = chart;
     SubGroups    = null;
 }
        /// <summary>
        /// Get Unicode range according to Unicode chart provided
        /// </summary>
        public static UnicodeRange GetUnicodeChartRange(UnicodeRangeDatabase unicodeDb, UnicodeChart chart)
        {
            foreach (Group script in unicodeDb.Scripts)
            {
                if (script.UnicodeChart == chart)
                {
                    return(script.UnicodeRange);
                }

                if (null != script.SubGroups)
                {
                    foreach (SubGroup subScript in script.SubGroups)
                    {
                        if (subScript.UnicodeChart == chart)
                        {
                            return(subScript.UnicodeRange);
                        }
                    }
                }
            }

            foreach (Group symbol in unicodeDb.SymbolsAndPunctuation)
            {
                if (symbol.UnicodeChart == chart)
                {
                    return(symbol.UnicodeRange);
                }

                if (null != symbol.SubGroups)
                {
                    foreach (SubGroup subSymbol in symbol.SubGroups)
                    {
                        if (subSymbol.UnicodeChart == chart)
                        {
                            return(subSymbol.UnicodeRange);
                        }
                    }
                }
            }

            throw new ArgumentException(@"Invalid UnicodeChart, " + Enum.GetName(typeof(UnicodeChart), chart) + ". No match in the database.");
        }