示例#1
0
        private static void TextUtilitiesExample()
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            List <char>   chars   = new List <char>();
            List <string> strings = new List <string>();

            for (int i = 0; i < 65536; ++i)
            {
                char c = Convert.ToChar(i);
                if (TextSupport.IsCharacterEntity(c))
                {
                    chars.Add(c);
                    strings.Add(TextSupport.PutCharacterEntity(c));
                }
            }
            Console.WriteLine(chars.Count + " total character entities:");
            string s = new string(chars.ToArray());
            int    j = 0;

            do
            {
                int l = Math.Min(20, s.Length - j);
                Console.WriteLine("\t" + s.Substring(j, l));
                j += 20;
            } while (j < s.Length);

            Console.WriteLine();
            for (int k = 0; k < chars.Count; ++k)
            {
                Console.WriteLine("\t" + chars[k] + " = " + strings[k]);
            }
        }
示例#2
0
 public void CharacterEntitiesTest()
 {
     for (int i = 0; i < characterEntities.Length; ++i)
     {
         char c0 = characterEntities[i];
         Assert.True(TextSupport.IsCharacterEntity(c0), String.Format("{0} ({1}) at index {2} is not a character entity.", c0, Convert.ToInt32(c0), i));
         string s0 = TextSupport.PutCharacterEntity(c0);
         Assert.NotEmpty(s0);
         char c1 = TextSupport.GetCharacterEntity(s0);
         Assert.Equal(c0, c1);
     }
 }