Javascript – Count bytes in textarea using javascript

javascriptutf-8

I need to count how long in bytes a textarea is when UTF8 encoded using javascript. Any idea how I would do this?

thanks!

Best Answer

encodeURIComponent(text).replace(/%[A-F\d]{2}/g, 'U').length