Hans Preutz Hans Preutz - 1 year ago 65
C# Question

In C#, String .Replace wont replace danish chars

so I have string containing a Danish char (æ), say:

string textString = "tæst";
string newString = "";

for some reason this

newString = textString .Replace("æ", "e");

Is not replacing correctly, it's resulting
newString = "tæst"
when it's supposed to be
newString = "test"

However, NOT ALWAYS!

I have tested on multiple servers, on some this is returned correctly as
on others this is

I am thinking in terms of, maybe the string is not recognized as a utf8 string, and should maybe be forced to be recognized as a utf8. Just a guess, do you have an idea/guess?


Answer Source
var s = "ӕæ".Replace("ӕ", "e"); // s = "eæ"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download