Utils: Add UTF8 encoding without BOM
This commit is contained in:
@ -2,7 +2,6 @@ using System;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Elwig.Documents {
|
namespace Elwig.Documents {
|
||||||
public abstract class Document : IDisposable {
|
public abstract class Document : IDisposable {
|
||||||
@ -63,7 +62,7 @@ namespace Elwig.Documents {
|
|||||||
public async Task Generate() {
|
public async Task Generate() {
|
||||||
var pdf = new TempFile("pdf");
|
var pdf = new TempFile("pdf");
|
||||||
using (var tmpHtml = new TempFile("html")) {
|
using (var tmpHtml = new TempFile("html")) {
|
||||||
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Encoding.UTF8);
|
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Utils.UTF8);
|
||||||
await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath);
|
await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath);
|
||||||
}
|
}
|
||||||
PdfFile = pdf;
|
PdfFile = pdf;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using IniParser;
|
using IniParser;
|
||||||
using IniParser.Model;
|
using IniParser.Model;
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ namespace Elwig.Helpers {
|
|||||||
var parser = new FileIniDataParser();
|
var parser = new FileIniDataParser();
|
||||||
IniData? ini = null;
|
IniData? ini = null;
|
||||||
try {
|
try {
|
||||||
ini = parser.ReadFile(FileName, Encoding.UTF8);
|
ini = parser.ReadFile(FileName, Utils.UTF8);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (ini == null || !ini.TryGetKey("database.file", out string db)) {
|
if (ini == null || !ini.TryGetKey("database.file", out string db)) {
|
||||||
@ -70,7 +69,7 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Write() {
|
public void Write() {
|
||||||
using var file = new StreamWriter(FileName, false, Encoding.UTF8);
|
using var file = new StreamWriter(FileName, false, Utils.UTF8);
|
||||||
file.Write($"\r\n[general]\r\n");
|
file.Write($"\r\n[general]\r\n");
|
||||||
if (Branch != null) file.Write($"branch = {Branch}\r\n");
|
if (Branch != null) file.Write($"branch = {Branch}\r\n");
|
||||||
file.Write($"\r\n[database]\r\nfile = {DatabaseFile}\r\n");
|
file.Write($"\r\n[database]\r\nfile = {DatabaseFile}\r\n");
|
||||||
|
@ -15,6 +15,8 @@ using Elwig.Models;
|
|||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public static partial class Utils {
|
public static partial class Utils {
|
||||||
|
|
||||||
|
public static readonly Encoding UTF8 = new UTF8Encoding(false, true);
|
||||||
|
|
||||||
public static int CurrentYear => DateTime.Now.Year;
|
public static int CurrentYear => DateTime.Now.Year;
|
||||||
public static int CurrentNextSeason => DateTime.Now.Year - (DateTime.Now.Month <= 3 ? 1 : 0);
|
public static int CurrentNextSeason => DateTime.Now.Year - (DateTime.Now.Month <= 3 ? 1 : 0);
|
||||||
public static int CurrentLastSeason => DateTime.Now.Year - (DateTime.Now.Month <= 7 ? 1 : 0);
|
public static int CurrentLastSeason => DateTime.Now.Year - (DateTime.Now.Month <= 7 ? 1 : 0);
|
||||||
|
Reference in New Issue
Block a user