Convert the UTF-16 encoded source string to UTF-8 : Encoding UTF8 « I18N Internationalization « C# / CSharp Tutorial






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));
        }
    }
}








21.14.Encoding UTF8
21.14.1.Encodings: Encoding.UTF8
21.14.2.Write the UTF-8 encoded byte arrays
21.14.3.Convert the UTF-16 encoded source string to UTF-8