Материал из .Net Framework эксперт
Convert the UTF-16 encoded source string to UTF-8
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[] utf8String = Encoding.UTF8.GetBytes(srcString);
output.WriteLine("UTF-8 Bytes: {0}", BitConverter.ToString(utf8String));
}
}
}
Encodings: Encoding.UTF8
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 utf8 = Encoding.UTF8;
Console.WriteLine(utf8);
}
}
System.Text.UTF8Encoding
Write the UTF-8 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[] utf8String = Encoding.UTF8.GetBytes(srcString);
output.WriteLine("UTF-8 Bytes: {0}", BitConverter.ToString(utf8String));
}
}
}