I am trying to export a file to an old programm that doesn't recognise Unicode(all my database uses utf8_unicode_ci encoding).
When I export the file, I then use Encoding.Default.
using (StreamWriter sw = new StreamWriter(parcours + "2", false, Encoding.Default))
{
foreach (string st in output)
{
sw.WriteLine("{0}", st);
}
}
But what is strange, is in some cases the file is correctly read, and in other cases not, but I use exactly the same function.
When I open with Notepad++, I can see that the file working is in ANSI, and the one not working is in Macintosh.
How can I always export ANSI? I guess using a Default value makes it to change encoding by itself?
nota : Here It is said that "ANSI" in notepad, just means it is not unicode, so I don't know if I can trust notepad's information?
Edit : As suggested by CodeCaster I used Windows-1251 Encoding, and I am back to the initial point, but at least I know that Encoding is where the error is?
Honestly I don't understand, in debug mode all the text is correct in my List. But in some cases the code is correctly encoded, in some cases not. Concretely here is what I mean by "works" :
ДВУТАВР20К2 is written ДВУТАВР20К2 in file (it works).
Двутавр12б1 is written ƒ¬”“ј¬–12Ѕ1 in file (doesn't work).
in string, there is no encoding as much as I know, so how could I explain that?