diff --git a/src/core/annotation.js b/src/core/annotation.js index 2582f79a0..4ee0ab1e3 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -27,7 +27,6 @@ import { FeatureTest, getModificationDate, IDENTITY_MATRIX, - isAscii, LINE_DESCENT_FACTOR, LINE_FACTOR, OPS, @@ -42,6 +41,7 @@ import { collectActions, getInheritableProperty, getRotationMatrix, + isAscii, numberToString, stringToUTF16String, } from "./core_utils.js"; diff --git a/src/core/core_utils.js b/src/core/core_utils.js index 6794f7768..e8be16014 100644 --- a/src/core/core_utils.js +++ b/src/core/core_utils.js @@ -572,6 +572,10 @@ function getNewAnnotationsMap(annotationStorage) { return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null; } +function isAscii(str) { + return /^[\x00-\x7F]*$/.test(str); +} + function stringToUTF16HexString(str) { const buf = []; for (let i = 0, ii = str.length; i < ii; i++) { @@ -622,6 +626,7 @@ export { getLookupTableFactory, getNewAnnotationsMap, getRotationMatrix, + isAscii, isWhiteSpace, log2, MissingDataException, diff --git a/src/shared/util.js b/src/shared/util.js index 4cf01b515..c6497750b 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -1051,10 +1051,6 @@ function escapeString(str) { }); } -function isAscii(str) { - return /^[\x00-\x7F]*$/.test(str); -} - function stringToUTF8String(str) { return decodeURIComponent(escape(str)); } @@ -1168,7 +1164,6 @@ export { InvalidPDFException, isArrayBuffer, isArrayEqual, - isAscii, LINE_DESCENT_FACTOR, LINE_FACTOR, MissingPDFException, diff --git a/test/unit/core_utils_spec.js b/test/unit/core_utils_spec.js index 6072855f9..010929d99 100644 --- a/test/unit/core_utils_spec.js +++ b/test/unit/core_utils_spec.js @@ -18,6 +18,7 @@ import { encodeToXmlString, escapePDFName, getInheritableProperty, + isAscii, isWhiteSpace, log2, parseXFAPath, @@ -335,6 +336,16 @@ describe("core_utils", function () { }); }); + describe("isAscii", function () { + it("handles ascii/non-ascii strings", function () { + expect(isAscii("hello world")).toEqual(true); + expect(isAscii("こんにちは世界の")).toEqual(false); + expect(isAscii("hello world in Japanese is こんにちは世界の")).toEqual( + false + ); + }); + }); + describe("stringToUTF16String", function () { it("should encode a string in UTF16", function () { expect(stringToUTF16String("hello world")).toEqual( diff --git a/test/unit/util_spec.js b/test/unit/util_spec.js index 3eab37e21..ed3726fde 100644 --- a/test/unit/util_spec.js +++ b/test/unit/util_spec.js @@ -20,7 +20,6 @@ import { escapeString, getModificationDate, isArrayBuffer, - isAscii, string32, stringToBytes, stringToPDFString, @@ -259,14 +258,4 @@ describe("util", function () { expect(getModificationDate(date)).toEqual("31410609020653"); }); }); - - describe("isAscii", function () { - it("handles ascii/non-ascii strings", function () { - expect(isAscii("hello world")).toEqual(true); - expect(isAscii("こんにちは世界の")).toEqual(false); - expect(isAscii("hello world in Japanese is こんにちは世界の")).toEqual( - false - ); - }); - }); });