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 instanceof Uint8Array checks.
Encode a string to UTF-8 bytes.
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 failsinstanceof Uint8Arraychecks.