Sunday, May 13, 2018

String length in bytes in JavaScript

String length in bytes in JavaScript

(new TextEncoder('utf-8').encode('foo')).length

Reference:

https://stackoverflow.com/questions/5515869/string-length-in-bytes-in-javascript

No comments: