Published on: 27 Jul, 2013

How to convert accented characters in ASP.Net C#?

Tumblr Digg Google Plus

They can be considered as special characters that contains specific symbols or accents attached to them. For ex: ÁÇËÌÖ

To convert those special characters in C#, you can use the following function.

//this function  will accept codepage in integer and accented characters in string
public string ConvertAccentedString(int codepage, string accentedString) {
    return System.Text.Encoding.ASCII.GetString( System.Text.Encoding.GetEncoding( codepage ).GetBytes( accentedString ));

The codepage represents the unicode of specific language. See below example list of codepage:

codepage unicode

How to use the function?

Please see the following example:

protected void Page_Load(object sender, EventArgs e) {
    string accentedString = "ÁÇËÌÖ";
    Response.Write("After conversion to string: " + ConvertAccentedString(1251, accentedString));  

The above demo will print the following result: ACEIO


Sebastien DErrico
18 Mar, 2016
Thank you! Very useful!
Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.