Wahtever
Wahtever

Reputation: 3678

How to remove certain characters from HTML code using ASP

Just like the title says, how do I tell the page to output the HTML code and remove certain characters, such as this character (ü)

Upvotes: 1

Views: 348

Answers (2)

Elian Ebbing
Elian Ebbing

Reputation: 19027

This is a method that removes diacritics:

public static string RemoveDiacritics(this string input)
{
    input = input.Normalize(NormalizationForm.FormD);
    StringBuilder output = new StringBuilder();

    for (int i = 0; i < input.Length; i++)
    {
        if (CharUnicodeInfo.GetUnicodeCategory(input[i]) != UnicodeCategory.NonSpacingMark) 
            output.Append(input[i]);
    }

    return output.ToString();
}

Example usage:

string str = RemoveDiacritics("éïå"); // str = "eia"

Upvotes: 2

smdrager
smdrager

Reputation: 7417

Do you mean specific enumerated characters, or all characters with diacritics? http://en.wikipedia.org/wiki/Diacritic

 myString = Replace(myString, "ü", "")

Upvotes: 0

Related Questions