This is used to pre-encode XML content before passing to JSZip,
which avoids a bug where JSZip's string chunking can split UTF-16
surrogate pairs for characters above U+FFFF (like emoji).
The copy via new Uint8Array() ensures the returned array uses the
current module's Uint8Array constructor, avoiding cross-realm issues
in test environments (jsdom) where TextEncoder returns a different
realm's Uint8Array that fails JSZip's instanceof checks.
Encode a string to UTF-8 bytes.
This is used to pre-encode XML content before passing to JSZip, which avoids a bug where JSZip's string chunking can split UTF-16 surrogate pairs for characters above U+FFFF (like emoji).
The copy via
new Uint8Array()ensures the returned array uses the current module's Uint8Array constructor, avoiding cross-realm issues in test environments (jsdom) where TextEncoder returns a different realm's Uint8Array that fails JSZip's instanceof checks.