demo · v136
PA text helpers
Wasm bidding scripts need cheap string ↔ bytes conversion to talk to WASM modules. protectedAudience.encodeUtf8 / decodeUtf8 are the new standalone helpers. Round-trip a string below.
Probing…
encoded bytes (length)—
encoded bytes (hex)—
decoded back—
matches TextEncoder?—
the code
// Inside a Protected Audience bidding / scoring script that calls into WASM:
const bytes = protectedAudience.encodeUtf8("Hello, 世界");
// pass bytes into WASM memory, get bytes back, then:
const str = protectedAudience.decodeUtf8(bytes);
// Outside PA, this is the equivalent shim:
const enc = new TextEncoder();
const dec = new TextDecoder();
enc.encode("Hello, 世界");
dec.decode(bytes);
see also
- PA text helpers — feature index
- ChromeStatus entry
- Protected Audience spec