mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Combine the stringToUTF16String
and stringToUTF16BEString
helper functions
Given that these functions are virtually identical, with the latter only adding a BOM, we can combine the two. Furthermore, since both functions were only used on the worker-thread, there's no reason to duplicate this functionality in both of the `pdf.js` and `pdf.worker.js` files.
This commit is contained in:
parent
c7d6ab2f71
commit
2eaa708e3a
5 changed files with 41 additions and 31 deletions
|
@ -584,8 +584,11 @@ function stringToUTF16HexString(str) {
|
|||
return buf.join("");
|
||||
}
|
||||
|
||||
function stringToUTF16String(str) {
|
||||
function stringToUTF16String(str, bigEndian = false) {
|
||||
const buf = [];
|
||||
if (bigEndian) {
|
||||
buf.push("\xFE\xFF");
|
||||
}
|
||||
for (let i = 0, ii = str.length; i < ii; i++) {
|
||||
const char = str.charCodeAt(i);
|
||||
buf.push(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue