c# - Handling Special Characters (¦) -


i'm bit lost on how read , write to/from text files in c# when special characters present. i'm writing simple script cleanup on .txt data file contains '¦' character delimiter.

 foreach (string file in directory.enumeratefiles(@"path\raw txt","*.txt"))             {                 string contents = file.readalltext(file);                               contents = contents.replace("¦", ",");                 file.writealltext(file.replace("raw txt", "txt"), contents);             } 

however, when open txt file in notepad++, delimeter �. going on? characters (¦) encoding / how determine that? i've tried adding things like:

string contents = file.readalltext(file, encoding.utf8); file.writealltext(file.replace("raw txt", "txt"), contents, encoding.utf8); 

everything working correctly switching encoding 'default' when both reading/writing.

string contents = file.readalltext(file, encoding.default); file.writealltext(file.replace("raw txt", "txt"), contents, encoding.default); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -