17 February 2014

How to convert string to utf-8 string in c#



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace adi.Web
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;

            string s = "adi";

            //string to utf
            byte[] utf = System.Text.Encoding.UTF8.GetBytes(s);

            //utf to string
            string s2 = System.Text.Encoding.UTF8.GetString(utf);
        }
    }
}

No comments:

Post a Comment