Loading topic
&, |, >>), and have read the previous chapter on how strings store UTF-16 code units. Here we look at the other side: how a Unicode code point becomes the bytes that files, HTTP bodies, and most API5 min readTextEncoder or build a base64 string, you need a place to keep those bytes. In JavaScript that place is an ArrayBuffer, 5 min readTextEncoder API. It covers the two methods, encode and encodeInto, how to size buffers for each, and the mistakes that tend to turn up in production code.5 min readUint8Array is a view over an ArrayBuffer. You should also have used TextEncoder.encode and be able to run cod5 min readUint8Array and TextEncoder from the earlier chapters. You will need a browser console or Node.js to run the examples.5 min read=. You should also be able to run snippets in a browser conso6 min readbtoa throws InvalidCharacterError on any character above U+00FF, and that atob returns a "binary string" rather than real text. This chapter turns those limits into a working pattern. You first encode text to UTF-8 bytes, then hand btoa a string with exactly 5 min readUint8Array to base64 through a binary string with btoa and atob. You should be comfortable with regular expressions and with TextEncoder and TextDecoder. Node's `Buff6 min readUint8Array holds bytes, and how base64 groups 3 bytes into 4 characters. It also assumes you have seen the browser workaround that sends bytes through a binary string before calling btoa. Node.js does not need that wo5 min readTextEncoder, TextDecoder, how base64 works, the btoa/atob workaround, base64url, and Node's Buffer. You should be comfortable with Uint8Array, destructuring, and try/catch.6 min readTextEncoder turns strings into UTF-8 bytes in a Uint8Array. Here we cover the one kind of string that cannot be enc5 min read