using System;
using System.Text;
public class Test {
public static void Main() {
try {
string cats = "\uD83D\uDE38\uD83D\uDE3E";
Console.WriteLine( cats );
Console.WriteLine( cats.Substring(1) );
Console.WriteLine( ReverseString(cats) ); //program crashes, generates no output!
Console.WriteLine( cats.Length );
string noel = "noe\u0308l";
Console.WriteLine( noel );
Console.WriteLine( ReverseString(noel) );
Console.WriteLine( noel.Substring(0,3) );
Console.WriteLine( noel.Length );
Console.WriteLine( Join( ",", noel.ToCharArray() ) );
string ligature = "ba\uFB04e";
Console.WriteLine( "Upper " + ligature + " => " + ligature.ToUpper() );
string cnoel = "noël";
Console.WriteLine( cnoel + " == " + noel + " (" + (cnoel == noel ? "true" : "false") + ")" );
Console.WriteLine( "Normalize " + cnoel + " == " + noel + " (" + (cnoel.Normalize() == noel.Normalize() ? "true" : "false") + ")" );
} catch( Exception ex ) {
Console.WriteLine( ex.Message );
}
}
public static string ReverseString(string s) {
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
public static string Join(string j, char[] cs) {
StringBuilder builder = new StringBuilder();
foreach( char c in cs ) {
builder.Append(c).Append(j);
}
return builder.ToString();
}
}