Lucas
Lucas

Reputation: 3502

Replace broken characters

I have a small programm that replace strings that contains umlauts, apostrophes etc.
But sometimes I haven broken strings that contains for example A¶ for ü, A¼ (or ü) for ö, and so on.
Is there a way to fix these strings?

I just tried to use another replace statement

  str = str.Replace("A¶", "ü");
  str = str.Replace("A¼", "ö");
  str = str.Replace("ü", "ö");

But this do not work for me

Upvotes: 1

Views: 481

Answers (1)

ElGavilan
ElGavilan

Reputation: 6894

It looks like because they are non-standard characters it is having trouble matching. You will probably have to use Regex.Replace and reference the Unicode value of the characters in your regex: How can you strip non-ASCII characters from a string? (in C#)

Unicode/UTF8 reference: http://www.utf8-chartable.de/

Complete Unicode character set: http://www.unicode.org/charts/

Upvotes: 1

Related Questions