All pastes #1977261 Raw Edit

Someone

public text v1 · immutable
#1977261 ·published 2010-10-30 14:47 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = new String(new char[] { '\u092e', '\u093e', '\u0930', '\u094d', '\u0915', ' ', '\u091c', '\u093c', '\u0941', '\u0915', '\u0947', '\u0930', '\u092c', '\u0930', '\u094d', '\u0917' });
            Show("s1", s1);
            Console.WriteLine("A1) Is s1 normalized to the default form (Form C)?: {0}",
                                 s1.IsNormalized());
            Console.WriteLine("A2) Is s1 normalized to Form C?:  {0}",
                                         s1.IsNormalized(NormalizationForm.FormC));
            Console.WriteLine("A3) Is s1 normalized to Form D?:  {0}",
                                         s1.IsNormalized(NormalizationForm.FormD));
            Console.WriteLine("A4) Is s1 normalized to Form KC?: {0}",
                                         s1.IsNormalized(NormalizationForm.FormKC));
            Console.WriteLine("A5) Is s1 normalized to Form KD?: {0}",
                                         s1.IsNormalized(NormalizationForm.FormKD));

            string s2 = s1.Normalize();
            Console.Write("B1) Is s2 normalized to the default form (Form C)?: ");
            Console.WriteLine(s2.IsNormalized());
            Show("s2", s2);
            Console.WriteLine();

            Console.ReadKey();

        }

        private static void Show(string title, string s)
        {
            Console.Write("Characters in string {0} = ", title);
            foreach (short x in s.ToCharArray())
            {
                Console.Write("{0:X4} ", x);
            }
            Console.WriteLine();
        }
    }
}