ASCIIEncoding Class represents an ASCII character encoding of Unicode characters.
using System;
using System.Text;
class MainClass{
public static void Main() {
ASCIIEncoding ascii = new ASCIIEncoding();
String unicodeString ="Pi (\u03a0) and Sigma (\u03a3).";
int indexOfPi = unicodeString.IndexOf('\u03a0');
int indexOfSigma = unicodeString.IndexOf('\u03a3');
Byte[] encodedBytes = ascii.GetBytes(unicodeString);
foreach (Byte b in encodedBytes) {
Console.Write("[{0}]", b);
}
String decodedString = ascii.GetString(encodedBytes);
Console.WriteLine(decodedString);
}
}
Related examples in the same category