mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-08-20 09:37:44 +08:00
Fix windows-1252 encoding not working on net6.0 and 8.0
This commit is contained in:
parent
7c36e203d0
commit
ec720b1c91
Binary file not shown.
@ -5,6 +5,22 @@
|
||||
|
||||
public class EncodingsTests
|
||||
{
|
||||
[Fact]
|
||||
public void Windows1252Encoding()
|
||||
{
|
||||
string path = IntegrationHelpers.GetDocumentPath("GHOSTSCRIPT-698363-0.pdf");
|
||||
using (var document = PdfDocument.Open(path))
|
||||
{
|
||||
var page = document.GetPage(1);
|
||||
string actual = string.Concat(page.Letters.Select(l => l.Value));
|
||||
|
||||
// The expected string value is just here to make sure we have the same results across net versions.
|
||||
// Feel free to correct/update it if chars are not actually correct.
|
||||
string expected = "ҘҹЧѥЧКጹѝঐܮ̂ҥ҇ҁӃ࿋\u0c0dҀғҊ˺෨ཌආр෨ཌ̂ҘҹЧѥЧКጹѝঐܮ̂ҥ҇ҁӃ࿋\u0c0dҀғҊ˺෨ཌආр෨ཌ̂ݰႺംࢥ༢࣭\u089aѽ̔ҫһҐ̔ݰႺംࢥ༢࣭\u089aѽ̔ҫһҐ̔";
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Issue688()
|
||||
{
|
||||
|
||||
@ -3,10 +3,11 @@
|
||||
public class IntegrationDocumentTests
|
||||
{
|
||||
private static readonly Lazy<string> DocumentFolder = new Lazy<string>(() => Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "Documents")));
|
||||
private static readonly HashSet<string> _documentsToIgnore = new HashSet<string>()
|
||||
{
|
||||
"issue_671.pdf"
|
||||
};
|
||||
private static readonly HashSet<string> _documentsToIgnore =
|
||||
[
|
||||
"issue_671.pdf",
|
||||
"GHOSTSCRIPT-698363-0.pdf"
|
||||
];
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetAllDocuments))]
|
||||
|
||||
@ -11,6 +11,13 @@
|
||||
|
||||
internal class NameTokenizer : ITokenizer
|
||||
{
|
||||
static NameTokenizer()
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool ReadsNextByte { get; } = true;
|
||||
|
||||
public bool TryTokenize(byte currentByte, IInputBytes inputBytes, out IToken token)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user