Here is an example:
str="äáöü";
console.log(str + ": " + str.length + " characters, " +
Buffer.byteLength(str, 'utf8') + " bytes");
// äáöü: 4 characters, 8 bytes
Buffer.byteLength(string, [encoding])
Here is an example:
str="äáöü";
console.log(str + ": " + str.length + " characters, " +
Buffer.byteLength(str, 'utf8') + " bytes");
// äáöü: 4 characters, 8 bytes
Buffer.byteLength(string, [encoding])