コード例 #1
0
ファイル: UnicodeMap.cs プロジェクト: bdqnghi/j2cstranslator
 /// <summary>
 /// Add all the (main) values from a Unicode property
 /// </summary>
 ///
 /// <param name="prop">the property to add to the map</param>
 /// <returns>this (for chaining)</returns>
 public UnicodeMap PutAll(UnicodeProperty prop)
 {
     // TODO optimize
     for (int i = 0; i <= 0x10FFFF; ++i)
     {
         _put(i, prop.GetValue(i));
     }
     return(this);
 }
コード例 #2
0
        static internal void GeneratePropertyAliases(bool showValues,
                                                     UnicodeProperty.Factory ups)
        {
            ComparatorInfo order  = System.Globalization.ComparatorInfo.GetInstance(System.Globalization.CultureInfo.CreateSpecificCulture("en"));
            SortedSet      props  = new SortedSet(order);
            SortedSet      values = new SortedSet(order);
            BagFormatter   bf     = new BagFormatter();

            ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(ups.GetAvailableNames(), props);
            for (int i = IBM.ICU.Charset.UnicodeProperty.BINARY; i < IBM.ICU.Charset.UnicodeProperty.LIMIT_TYPE; ++i)
            {
                System.Console.Out.WriteLine(IBM.ICU.Charset.UnicodeProperty.GetTypeName(i));
                IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(props.GetEnumerator());
                while (it.HasNext())
                {
                    String          propAlias = (String)it.Next();
                    UnicodeProperty up        = ups.GetProperty(propAlias);
                    int             type      = up.GetType();
                    if (type != i)
                    {
                        continue;
                    }
                    System.Console.Out.WriteLine();
                    System.Console.Out.WriteLine(propAlias + "\t"
                                                 + bf.Join(up.GetNameAliases()));
                    if (!showValues)
                    {
                        continue;
                    }
                    ILOG.J2CsMapping.Collections.Collections.Clear(values);
                    if (type == IBM.ICU.Charset.UnicodeProperty.NUMERIC ||
                        type == IBM.ICU.Charset.UnicodeProperty.EXTENDED_NUMERIC)
                    {
                        UnicodeMap um = new UnicodeMap();
                        um.PutAll(up);
                        System.Console.Out.WriteLine(um.ToString(new TestBagFormatter.NumberComparator()));
                        continue;
                    }
                    ILOG.J2CsMapping.Collections.Collections.Clear(values);
                    ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(up.GetAvailableValues(), values);
                    IIterator it2 = new ILOG.J2CsMapping.Collections.IteratorAdapter(values.GetEnumerator());
                    while (it2.HasNext())
                    {
                        String valueAlias = (String)it2.Next();
                        System.Console.Out.WriteLine("\t"
                                                     + bf.Join(valueAlias + "\t"
                                                               + up.GetValueAliases(valueAlias)));
                    }
                }
            }
        }
コード例 #3
0
        public static void Main(String[] args)
        {
            System.Console.Out.WriteLine("Start");
            try {
                // readCharacters();
                UnicodeProperty prop = IBM.ICU.Charset.ICUPropertyFactory.Make().GetProperty(
                    "Canonicalcombiningclass");
                prop.GetAvailableValues();

                GeneratePropertyAliases(true);

                BagFormatter bf = new BagFormatter();

                UnicodeSet us = new UnicodeSet("[:gc=nd:]");
                IBM.ICU.Charset.BagFormatter.CONSOLE.WriteLine("[:gc=nd:]");
                bf.ShowSetNames(IBM.ICU.Charset.BagFormatter.CONSOLE, us);

                us = new UnicodeSet("[:numeric_value=2:]");
                IBM.ICU.Charset.BagFormatter.CONSOLE.WriteLine("[:numeric_value=2:]");
                bf.ShowSetNames(IBM.ICU.Charset.BagFormatter.CONSOLE, us);

                us = new UnicodeSet("[:numeric_type=numeric:]");
                IBM.ICU.Charset.BagFormatter.CONSOLE.WriteLine("[:numeric_type=numeric:]");
                bf.ShowSetNames(IBM.ICU.Charset.BagFormatter.CONSOLE, us);

                UnicodeProperty.Factory ups = IBM.ICU.Charset.ICUPropertyFactory.Make();
                us = ups.GetSet("gc=mn", null, null);
                IBM.ICU.Charset.BagFormatter.CONSOLE.WriteLine("gc=mn");
                bf.ShowSetNames(IBM.ICU.Charset.BagFormatter.CONSOLE, us);

                if (true)
                {
                    return;
                }
                // showNames("Name", ".*MARK.*");
                // showNames("NFD", "a.+");
                // showNames("NFD", false);
                // showNames("Lowercase_Mapping", false);
                // TestUnicodePropertySource.test(true);
                // showNames(".*\\ \\-.*");

                // checkHTML();
                // testIsRTL();

                // TestTokenizer.test();
                // RandomCollator.generate("collationTest.txt", null);

                // TestPick.test();
                // printRandoms();
                // if (true) return;
                // testLocales();
                // if (true) return;

                /*
                 * TestCollator tc = new TestCollator();
                 * tc.test(RuleBasedCollator.getInstance(),1000);
                 */
                /*
                 * StringBuffer sb = new StringBuffer(); for (int i = 0; i < 100;
                 * ++i) { sb.setLength(0); rc.nextRule(sb); System.out.println(sb);
                 * }
                 */
            } finally {
                System.Console.Out.WriteLine("End");
            }
        }