Skip to content

Commit

Permalink
Replaced UDE.Net with UTFUnknown and downgraded some nuget packages t…
Browse files Browse the repository at this point in the history
…o solve version conflicts
  • Loading branch information
Kees committed Aug 23, 2023
1 parent 1c98b28 commit 7256e1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
8 changes: 4 additions & 4 deletions ChromiumHtmlToPdfConsole/ChromiumHtmlToPdfConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.0.4" />
<PackageReference Include="AngleSharp.Io" Version="1.0.0" />
<PackageReference Include="AngleSharp.Xml" Version="1.0.0" />
<PackageReference Include="AngleSharp" Version="0.17.1" />
<PackageReference Include="AngleSharp.Io" Version="0.17.0" />
<PackageReference Include="AngleSharp.Xml" Version="0.17.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions ChromiumHtmlToPdfLib/ChromiumHtmlToPdfLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.0.4" />
<PackageReference Include="AngleSharp" Version="0.17.1" />
<PackageReference Include="AngleSharp.Css" Version="0.17.0" />
<PackageReference Include="AngleSharp.Io" Version="1.0.0" />
<PackageReference Include="AngleSharp.Xml" Version="1.0.0" />
<PackageReference Include="AngleSharp.Io" Version="0.17.0" />
<PackageReference Include="AngleSharp.Xml" Version="0.17.0" />
<PackageReference Include="HtmlSanitizer" Version="8.0.692" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Management" Version="7.0.2" />
<PackageReference Include="Ude.NetStandard" Version="1.2.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 2 additions & 20 deletions ChromiumHtmlToPdfLib/Helpers/PreWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,11 @@ public string WrapFile(string inputFile, Encoding encoding)

if (encoding == null)
{
var charsetDetector = new Ude.CharsetDetector();
using (var fileStream = File.OpenRead(inputFile))
{
WriteToLog("Trying to detect encoding");
charsetDetector.Feed(fileStream);
charsetDetector.DataEnd();
if (charsetDetector.Charset != null)
{
try
{
encoding = Encoding.GetEncoding(charsetDetector.Charset);
}
catch
{
Console.WriteLine("Detection failed assuming standard encoding");
encoding = Encoding.Default;
}
}
else
{
Console.WriteLine("Detection failed assuming standard encoding");
encoding = Encoding.Default;
}
encoding = UtfUnknown.CharsetDetector.DetectFromStream(fileStream).Detected.Encoding;
WriteToLog($"Encoding detected as '{encoding.WebName}'");
}
}

Expand Down

0 comments on commit 7256e1e

Please sign in to comment.