1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Use the hexNumbers structure in the stringToUTF16HexString helper

We can re-use the `hexNumbers` structure here, since that allows us to directly lookup the hexadecimal values and shortens the code.
This commit is contained in:
Jonas Jenwald 2024-11-02 15:00:32 +01:00
parent 06f3b2d0a6
commit 2145a7b9ca
2 changed files with 3 additions and 4 deletions

View file

@ -17,6 +17,7 @@ import {
AnnotationEditorPrefix,
assert,
BaseException,
hexNumbers,
objectSize,
stringToPDFString,
Util,
@ -634,10 +635,7 @@ function stringToUTF16HexString(str) {
const buf = [];
for (let i = 0, ii = str.length; i < ii; i++) {
const char = str.charCodeAt(i);
buf.push(
((char >> 8) & 0xff).toString(16).padStart(2, "0"),
(char & 0xff).toString(16).padStart(2, "0")
);
buf.push(hexNumbers[(char >> 8) & 0xff], hexNumbers[char & 0xff]);
}
return buf.join("");
}

View file

@ -1149,6 +1149,7 @@ export {
getModificationDate,
getUuid,
getVerbosityLevel,
hexNumbers,
IDENTITY_MATRIX,
ImageKind,
info,