Пример #1
0
        public void TestNormalizedUnicodeChar()
        {
            // thai should have normalization on
            RuleBasedCollator th_th = null;

            try
            {
                th_th = (RuleBasedCollator)Collator.GetInstance(
                    new CultureInfo("th-TH"));
            }
            catch (Exception e)
            {
                Warnln("Error creating Thai collator");
                return;
            }
            StringBuffer source = new StringBuffer();

            source.Append('\uFDFA');
            CollationElementIterator iter
                = th_th.GetCollationElementIterator(source.ToString());

            CollationTest.BackAndForth(this, iter);
            for (char codepoint = (char)0x1; codepoint < 0xfffe;)
            {
                source.Delete(0, source.Length);
                while (codepoint % 0xFF != 0)
                {
                    if (UChar.IsDefined(codepoint))
                    {
                        source.Append(codepoint);
                    }
                    codepoint++;
                }

                if (UChar.IsDefined(codepoint))
                {
                    source.Append(codepoint);
                }

                if (codepoint != 0xFFFF)
                {
                    codepoint++;
                }

                /*if (((int)codepoint) >= 0xfe00) {
                 *  String str = source.substring(185, 190);
                 *  System.out.println(com.ibm.icu.impl.Utility.escape(str));
                 *  System.out.println("codepoint "
                 + Integer.toHexString(codepoint)
                 + "length " + str.Length);
                 +  iter = th_th.GetCollationElementIterator(str);
                 +  CollationTest.BackAndForth(this, iter);
                 */
                iter = th_th.GetCollationElementIterator(source.ToString());
                // A basic test to see if it's working at all
                CollationTest.BackAndForth(this, iter);
            }
        }
Пример #2
0
        public void TestUnicodeChar()
        {
            RuleBasedCollator        en_us = (RuleBasedCollator)Collator.GetInstance(new CultureInfo("en-US"));
            CollationElementIterator iter;
            char         codepoint;
            StringBuffer source = new StringBuffer();

            source.Append("\u0e4d\u0e4e\u0e4f");
            // source.append("\u04e8\u04e9");
            iter = en_us.GetCollationElementIterator(source.ToString());
            // A basic test to see if it's working at all
            CollationTest.BackAndForth(this, iter);
            for (codepoint = (char)1; codepoint < 0xFFFE;)
            {
                source.Delete(0, source.Length);
                while (codepoint % 0xFF != 0)
                {
                    if (UChar.IsDefined(codepoint))
                    {
                        source.Append(codepoint);
                    }
                    codepoint++;
                }

                if (UChar.IsDefined(codepoint))
                {
                    source.Append(codepoint);
                }

                if (codepoint != 0xFFFF)
                {
                    codepoint++;
                }

                /*if (codepoint >= 0x04fc) {
                 *  System.out.println("codepoint " + Integer.toHexString(codepoint));
                 *  String str = source.substring(230, 232);
                 *  System.out.println(com.ibm.icu.impl.Utility.escape(str));
                 *  System.out.println("codepoint " + Integer.toHexString(codepoint)
                 + "length " + str.Length);
                 +  iter = en_us.GetCollationElementIterator(str);
                 +  CollationTest.BackAndForth(this, iter);
                 + }
                 */
                iter = en_us.GetCollationElementIterator(source.ToString());
                // A basic test to see if it's working at all
                CollationTest.BackAndForth(this, iter);
            }
        }