I read data from utf-8 encoded file. Part of content of this file is then used as a name for newly created folder. However, my folder name is:
bohou�_120328 instead of bohouš_120328
How can I set proper coding for the name of newly created folder? Thanks.
edit:
I am reading information from file this way:
System.IO.StreamReader file = new System.IO.StreamReader(nameOfFile);
while ((j = file.ReadLine()) != null) {
//manipulating string in j
}
then creating directory with
if (Directory.Exists(folder) == false) {
Console.WriteLine("creating directory " + folder);
System.IO.Directory.CreateDirectory(@folder);
}
If I run my application on my Windows 7, 64bit computer, everything is fine. However, if I run in on other computers with older systems like WinXP, coding is just wrong and looks like this
bohou�_120328
Before using variable to creating folder, I write i to output, but everything is fine. Even folder names are fine. But just on my computer, unfortunately.
edit2:
Things are getting even more weird. I used this code How do I remove diacritics (accents) from a string in .NET? to remove diacritics, because names without diacritics are just fine for me.
However, again:
- running code on my computer yields into bohous_120328
- running code on other computers AND my flash disk yields into bohou�_120328
I swear it is the same code, as I COPIED my .exe file.
Debugger says that the problem is already in my string variable before creating folder. I do not understand, how the environment influences my variables in this case.
Will be happy for explanation :-)