diff --git a/src/core/core_utils.js b/src/core/core_utils.js index 5556c9e15..bbc7ef735 100644 --- a/src/core/core_utils.js +++ b/src/core/core_utils.js @@ -533,7 +533,7 @@ function encodeToXmlString(str) { buffer.push(str.substring(start, i)); } buffer.push(`&#x${char.toString(16).toUpperCase()};`); - if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) { + if (char > 0xffff) { // char is represented by two u16 i++; } diff --git a/test/unit/core_utils_spec.js b/test/unit/core_utils_spec.js index a9c6bd8f0..597f2cfbf 100644 --- a/test/unit/core_utils_spec.js +++ b/test/unit/core_utils_spec.js @@ -312,6 +312,11 @@ describe("core_utils", function () { const str = "hello world"; expect(encodeToXmlString(str)).toEqual(str); }); + + it("should keep the character after U+FFFE or U+FFFF", function () { + expect(encodeToXmlString("￿A")).toEqual("￿A"); + expect(encodeToXmlString("￾B")).toEqual("￾B"); + }); }); describe("validateCSSFont", function () {