(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Convert the UTF-16 encoded source string to ASCII
using System;
using System.IO;
using System.Text;
class MainClass
{
public static void Main()
{
using (StreamWriter output = new StreamWriter("output.txt"))
{
string srcString = "Area = \u03A0r^2";
byte[] asciiString = Encoding.ASCII.GetBytes(srcString);
output.WriteLine("ASCII Bytes: {0}",
BitConverter.ToString(asciiString));
}
}
}
Encodings: Encoding.ASCII
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Globalization;
public class MainClass
{
public static void Main()
{
Encoding ascii = Encoding.ASCII;
Console.WriteLine(ascii);
}
}
System.Text.ASCIIEncoding
Write the ASCII encoded byte arrays
using System;
using System.IO;
using System.Text;
class MainClass
{
public static void Main()
{
using (StreamWriter output = new StreamWriter("output.txt"))
{
string srcString = "Area = \u03A0r^2";
byte[] asciiString = Encoding.ASCII.GetBytes(srcString);
output.WriteLine("ASCII Bytes: {0}",
BitConverter.ToString(asciiString));
}
}
}