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:
parent
06f3b2d0a6
commit
2145a7b9ca
2 changed files with 3 additions and 4 deletions
|
@ -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("");
|
||||
}
|
||||
|
|
|
@ -1149,6 +1149,7 @@ export {
|
|||
getModificationDate,
|
||||
getUuid,
|
||||
getVerbosityLevel,
|
||||
hexNumbers,
|
||||
IDENTITY_MATRIX,
|
||||
ImageKind,
|
||||
info,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue