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
Post a Comment