SyntaxFix
Write A Post
Hire A Developer
Questions
For simple UTF-8 encoding, with slightly better compatibility than TextEncoder, Blob does the trick. Won't work in very old browsers though.
TextEncoder
new Blob([""]).size; // -> 4