Hello there, I am dealing with files encoded in UTF8 and I can't find a way to convert them into ANSI.
I've already searched in google for this since a while, and I'm not achieving the result I want to achieve if I use the code I've found on the web, which is the following:
Example of test.txt (save it as UTF8): "éàèüöä"
- string filePath = "c:\\test.txt";
-
-
StreamReader fileStream = new StreamReader(filePath);
-
string fileContent = fileStream.ReadToEnd();
-
fileStream.Close();
-
-
StreamWriter ansiWriter = new StreamWriter(filePath.Replace(".txt", "-ansi.txt"), false);
-
ansiWriter.Write(fileContent, Encoding.Default);
-
ansiWriter.Close();
What I get is as result as c:\test-ansi.txt the same file (same size) and same encoding. What I can conclude is that the "Default" encoding of my machine is UTF8.
So then my question is, can you help me to correct the code snippet above so that the "ANSI" encoding will be used, instead of the "Default" one? In Encoding I can find only ASCII, UTF7, UTF16, Unicode and UTF8, I couldn't find the ANSI one...
Thanks in advance, you can't imagine how many tests I did so far...