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
@ -17,6 +17,7 @@ import {
|
|||||||
AnnotationEditorPrefix,
|
AnnotationEditorPrefix,
|
||||||
assert,
|
assert,
|
||||||
BaseException,
|
BaseException,
|
||||||
|
hexNumbers,
|
||||||
objectSize,
|
objectSize,
|
||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
Util,
|
Util,
|
||||||
@ -634,10 +635,7 @@ function stringToUTF16HexString(str) {
|
|||||||
const buf = [];
|
const buf = [];
|
||||||
for (let i = 0, ii = str.length; i < ii; i++) {
|
for (let i = 0, ii = str.length; i < ii; i++) {
|
||||||
const char = str.charCodeAt(i);
|
const char = str.charCodeAt(i);
|
||||||
buf.push(
|
buf.push(hexNumbers[(char >> 8) & 0xff], hexNumbers[char & 0xff]);
|
||||||
((char >> 8) & 0xff).toString(16).padStart(2, "0"),
|
|
||||||
(char & 0xff).toString(16).padStart(2, "0")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return buf.join("");
|
return buf.join("");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1149,6 +1149,7 @@ export {
|
|||||||
getModificationDate,
|
getModificationDate,
|
||||||
getUuid,
|
getUuid,
|
||||||
getVerbosityLevel,
|
getVerbosityLevel,
|
||||||
|
hexNumbers,
|
||||||
IDENTITY_MATRIX,
|
IDENTITY_MATRIX,
|
||||||
ImageKind,
|
ImageKind,
|
||||||
info,
|
info,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user