I have textbox, in which the user can enter the characters in ASCII/UTF-8 or a combination of both. Is there any API in javascript which we can calculate the length of string in
As of 2018, the most compatible and reliable way of doing this seems to be with the blob api.
new Blob([str]).size
Even supported in IE10 if anyone uses that anymore.