Exemple #1
0
        static void Main(string[] args)
        {
            var d = new DecimalToUnicodeConverter();
            var c = new ConverterFunction();
            var e = new ExitFunction();

            DoWelcomeScreen();
        }
Exemple #2
0
        void Convert()
        {
            Console.Clear();


            int[]  cp437       = new int[256];
            string encoderName = SelectEncodingFile();

            string[] cp437Lines = File.ReadAllLines(Directory.GetCurrentDirectory() + "\\" + encoderName);
            foreach (var l in cp437Lines)
            {
                int index = int.Parse(l.Split(':').First());
                int val   = int.Parse(l.Split(':')[1]);
                cp437[index] = val;
            }


            string textFile = SelectTextFile();

            byte[] fileBytes = File.ReadAllBytes(Directory.GetCurrentDirectory() + "\\" + textFile);
            int[]  unicode   = new int[fileBytes.Length];

            FileStream f         = File.OpenWrite(Directory.GetCurrentDirectory() + "\\output.txt");
            Stopwatch  stopWatch = new Stopwatch();

            stopWatch.Start();
            Console.WriteLine("Writing...");
            for (int i = 0; i < fileBytes.Length; i++)
            {
                int currentByteValue = fileBytes[i];
                unicode[i] = cp437[currentByteValue];
                string unicodeString = char.ConvertFromUtf32(unicode[i]).ToString();
                f.Write(DecimalToUnicodeConverter.GetBytesFromUnicodeCodePoint(unicode[i]), 0, DecimalToUnicodeConverter.GetBytesFromUnicodeCodePoint(unicode[i]).Length);
            }
            f.Close();
            Console.WriteLine("Finished writing to output.txt!");
            stopWatch.Stop();
            Console.WriteLine("Time elapsed: " + stopWatch.ElapsedMilliseconds + " ms");
            Console.ReadKey();
            Program.DoWelcomeScreen();
        }