47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
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;
|
|
|
|
namespace Txt2Bib
|
|
{
|
|
internal class Text2Bib
|
|
{
|
|
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);
|
|
// How to determine actual encoding??
|
|
/*
|
|
result += reader.CurrentEncoding.CodePage switch
|
|
{
|
|
65001 => Encoding.UTF8.GetString(contentBytes),
|
|
_ => Encoding.Latin1.GetString(contentBytes)
|
|
};
|
|
*/
|
|
|
|
}
|
|
|
|
//TODO process entry
|
|
foreach (string item in result.Split('%'))
|
|
{
|
|
output += item;
|
|
}
|
|
|
|
return output;
|
|
}
|
|
}
|
|
}
|