calculate the bytes in JS string