From f1d4a4290da881745e2b0b24df8a62dc9c88fbd1 Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Sat, 2 Aug 2025 07:17:33 +0800 Subject: [PATCH] Fixed multibyte characters in MOBI fragment selectors (#91) For Chinese/CJK text, multibyte character offsets were being incorrectly used as bytes offsets after decoding --- mobi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobi.js b/mobi.js index 4917af6..939d6dd 100644 --- a/mobi.js +++ b/mobi.js @@ -1142,7 +1142,7 @@ class KF8 { const offsets = this.#fragmentOffsets.get(frag.index) if (offsets) for (const offset of offsets) { - const str = this.mobi.decode(fragRaw).slice(offset) + const str = this.mobi.decode(fragRaw.slice(offset)) const selector = getFragmentSelector(str) this.#setFragmentSelector(frag.index, offset, selector) }