Quantcast
Channel: String length in bytes in JavaScript - Stack Overflow
Viewing all articles
Browse latest Browse all 19

Answer by simap for String length in bytes in JavaScript

$
0
0

For simple UTF-8 encoding, with slightly better compatibility than TextEncoder, Blob does the trick. Won't work in very old browsers though.

new Blob(["😀"]).size; // -> 4  

Viewing all articles
Browse latest Browse all 19

Trending Articles