Parent: #473 Related: #666, #676
Problem
TextEncoder.encode already coerces source through the representation-aware WTF-8 helper, but TextEncoder.encodeInto still uses toStringV and then decodes those bytes as canonical WTF-8. With physical flat Latin-1 storage active, non-ASCII Latin-1 input is decoded as malformed data and emitted as U+FFFD instead of the required UTF-8 bytes, diverging from encode and misreporting written.
Scope
- Route encodeInto source coercion through the representation-aware WTF-8 helper.
- Preserve exactly one ToString coercion, destination validation/order, no-partial-scalar writes, UTF-16
readaccounting, bytewrittenaccounting, lone-surrogate replacement, shared/resizable buffer locking, ASCII borrowing, exception identity, and OOM propagation. - Cover exact non-ASCII bytes and encode/encodeInto parity under canonical and physical flat-Latin-1 storage.
No-workaround rules
- No flat-storage disablement, eager global canonicalization, replacement of valid Latin-1 text, duplicate coercion, alternate host encoder, hidden retry, or Test262 exclusion.
- No stack, queue, job, Promise, Worker, agent, or Map/Set iterator changes.
Acceptance
- encodeInto consumes canonical semantic WTF-8.
- Valid Latin-1 input emits exact UTF-8 bytes without replacement.
readremains UTF-16 code units andwrittenremains output bytes.- A custom ToString hook runs exactly once before destination writes.
- The witness passes with canonical storage and with
flat_storage_activeenabled, then the switch is restored and not landed. - Focused Web API Debug/ReleaseSafe/TSan and full units pass with the exact test inventory reported.