Be more specific on StreamWriter and template encoding to avoid EncoderFallbackException

This commit is contained in:
rlv-dan 2020-05-05 18:16:38 +02:00
parent 1726eb9301
commit 87914ff327
2 changed files with 5 additions and 3 deletions

View File

@ -53,7 +53,7 @@ namespace Snap2HTML
var sbTemplate = new StringBuilder();
try
{
using( System.IO.StreamReader reader = new System.IO.StreamReader( System.IO.Path.GetDirectoryName( Application.ExecutablePath ) + System.IO.Path.DirectorySeparatorChar + "template.html" ) )
using( System.IO.StreamReader reader = new System.IO.StreamReader( System.IO.Path.GetDirectoryName( Application.ExecutablePath ) + System.IO.Path.DirectorySeparatorChar + "template.html", Encoding.UTF8 ) )
{
sbTemplate.Append(reader.ReadToEnd());
}
@ -102,8 +102,10 @@ namespace Snap2HTML
// Write output file
try
{
using( System.IO.StreamWriter writer = new System.IO.StreamWriter( settings.outputFile ) )
using( System.IO.StreamWriter writer = new System.IO.StreamWriter( settings.outputFile, false, Encoding.UTF8 ) )
{
writer.AutoFlush = true;
var template = sbTemplate.ToString();
var startOfData = template.IndexOf( "[DIR DATA]" );

View File

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML>
<!-- saved from url=(0016)http://localhost -->
<!-- This file was generated by [APP NAME] [APP VER] at [GEN DATE] [GEN TIME]. See [APP LINK] for more information -->
<html>