mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Support UTF-16 little-endian strings in the stringToPDFString
helper function (bug 1593902)
The bug report seem to suggest that we don't support UTF-16 strings with a BOM (byte order mark), which we *actually* do as evident by both the code and a unit-test. The issue at play here is rather that we previously only supported big-endian UTF-16 BOM, and the `Title` string in the PDF document is using a *little-endian* UTF-16 BOM instead. Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1593902
This commit is contained in:
parent
de77d6686c
commit
80342e2fdc
2 changed files with 16 additions and 1 deletions
|
@ -179,11 +179,16 @@ describe('util', function() {
|
|||
expect(stringToPDFString(str)).toEqual('\u201Cstring\u201D');
|
||||
});
|
||||
|
||||
it('handles UTF-16BE strings', function() {
|
||||
it('handles UTF-16 big-endian strings', function() {
|
||||
let str = '\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67';
|
||||
expect(stringToPDFString(str)).toEqual('string');
|
||||
});
|
||||
|
||||
it('handles UTF-16 little-endian strings', function() {
|
||||
let str = '\xFF\xFE\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67\x00';
|
||||
expect(stringToPDFString(str)).toEqual('string');
|
||||
});
|
||||
|
||||
it('handles empty strings', function() {
|
||||
// ISO Latin 1
|
||||
let str1 = '';
|
||||
|
@ -192,6 +197,10 @@ describe('util', function() {
|
|||
// UTF-16BE
|
||||
let str2 = '\xFE\xFF';
|
||||
expect(stringToPDFString(str2)).toEqual('');
|
||||
|
||||
// UTF-16LE
|
||||
let str3 = '\xFF\xFE';
|
||||
expect(stringToPDFString(str3)).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue