Demonstrates the String.Normalize method and the String.IsNormalized method : String « String « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » String » String 
5.1.24.Demonstrates the String.Normalize method and the String.IsNormalized method
using System;
using System.Text;

class Sample 
{
    public static void Main() 
    {
        string s1 = new Stringnew char[] {'\u0063''\u0301''\u0327''\u00BE'});
        string s2 = null;
    
        try 
        {
            s2 = s1.Normalize();
            Console.WriteLine(s2.IsNormalized());
            Show("s2", s2);
        
            s2 = s1.Normalize(NormalizationForm.FormC);
            Console.WriteLine(s2.IsNormalized(NormalizationForm.FormC));
            Show("s2", s2);
        
        
            s2 = s1.Normalize(NormalizationForm.FormD);
            Console.WriteLine(s2.IsNormalized(NormalizationForm.FormD));
            Show("s2", s2);
        
            s2 = s1.Normalize(NormalizationForm.FormKC);
            Console.WriteLine(s2.IsNormalized(NormalizationForm.FormKC));
            Show("s2", s2);
        
            s2 = s1.Normalize(NormalizationForm.FormKD);
            Console.WriteLine(s2.IsNormalized(NormalizationForm.FormKD));
            Show("s2", s2);
        
        }catch (Exception e) {
            Console.WriteLine(e.Message);
        }
    }

    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);
        }
    }
}
5.1.String
5.1.1.Declaration of string
5.1.2.String is object
5.1.3.String are immutable
5.1.4.Empty string
5.1.5.Display all the characters in myString using a for loop
5.1.6.Use Indexer to reference chars in a string
5.1.7.Use the Compare() method to compare strings
5.1.8.Use the Concat() method to concatenate strings
5.1.9.Use the addition operator (+) to concatenate strings
5.1.10.Use the Copy() method to copy a string
5.1.11.Use the Equals() method and equality operator to check if two strings are equal
5.1.12.Use the Format() method to format a string
5.1.13.Use the Join() method to join strings
5.1.14.Use the Split() method to split strings
5.1.15.Use the IndexOfAny() and LastIndexOfAny() methods to search for character arrays in a string
5.1.16.Use the Insert(), Remove(), and Replace() methods to modify strings
5.1.17.Use the PadLeft() and PadRight() methods to align strings
5.1.18.Use the Trim(), TrimStart(), and TrimEnd() methods to trim strings
5.1.19.Use the Substring() method to retrieve substrings
5.1.20.Working with Strings
5.1.21.Error; string Is Immutable
5.1.22.Basic String functionality
5.1.23.Is String Interned
5.1.24.Demonstrates the String.Normalize method and the String.IsNormalized method
5.1.25.Whether a string is successfully normalized to various normalization forms.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.