I'm having a stupid problem. I'm reading some .cs files from disk. Doing lots of regex and other operations on them with a .net program i've made. Then write them back to disc.
The resulting files get the wrong encoding somehow. What encoding are c# source files? And then there is the first byte-order thing, is that needed? Does it get written when i use File.WriteAllText()?
The program changing the files is a simple .net application, and the code is simply
string text = System.IO.File.ReadAllText(fn);
string newText = Regex.Replace(text, regexStr, replaceStr);
System.IO.File.WriteAllText(fn, newText);
The c# files have comments and strings don't seem to be part of the standard codepage.
One of the problematic characters is "ä"
Solution:
this seems to work correctly
string text = System.IO.File.ReadAllText(fn, Encoding.GetEncoding(1252));
string newText = Regex.Replace(text, regexStr, replaceStr);
System.IO.File.WriteAllText(fn, newText, Encoding.GetEncoding(1252));