public void TestConvertString_ShouldReturnCorrectResult() { string expected = "COORDTYPE 1970,Балтийска,K5"; string actual = CyrillicHelper.ConvertString("COORDTYPE 1970,Ѓ «ІЁ©±Є ,K5"); Assert.AreEqual(expected, actual); }
public static void Main(string[] args) { Program.InitConsoleWindow(); while (true) { Console.Write("Enter path: "); string path = Console.ReadLine(); string[] files = Directory.GetFiles(path); foreach (var file in files) { if (File.Exists(file)) { StringBuilder output = new StringBuilder(); using (StreamReader reader = new StreamReader(file, Encoding.Default)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); var convertedString = CyrillicHelper.ConvertString(line); output.AppendLine(convertedString); } } string directory = Path.GetDirectoryName(file); string fileName = Path.GetFileNameWithoutExtension(file); string extension = Path.GetExtension(file); File.WriteAllText(string.Format("{0}{1}{2}_converted{3}", directory, Path.DirectorySeparatorChar, fileName, extension), output.ToString(), Encoding.Default); Console.WriteLine(string.Format("File {0}{1} has been successfully converted!", fileName, extension)); } } } }