using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls.Primitives; using System.Windows; using Txt2Bib.Records; using System.ComponentModel.DataAnnotations; namespace Txt2Bib { internal class Text2Bib { private readonly Dictionary _citTypes = new() { { "J" , "article"}, { "B", "book" }, { "P", "conference" }, { "C" , "inbook" } }; /// /// Generate single .bib file from input text files /// /// /// public string Generate(string filenames) { var paths = filenames.Trim().Split('\n'); string result = ""; string output = ""; foreach (var path in paths) { var reader = File.OpenText(path); byte[] contentBytes = File.ReadAllBytes(path); result += Encoding.Latin1.GetString(contentBytes); } var entries = result.Split('%').ToList().Select(entry => { return Process(entry); }); foreach (var entry in entries) { output += entries; } return output; } private IBib Process(string entryFromTxt) { return new ArticleBib(); } /// /// TODO: How to determine correct encoding of text file?? /// /// The stream reader for the file /// private Encoding GuessEncoding(StreamReader reader) { var cp = "UTF-8"; return Encoding.GetEncoding(cp); } } }