NetSuite counts “line break” as two characters. So, to count the characters in a long text field using script, must count “line break” as two characters.
Using script, we can count the characters by using length property of a string object which returns the number of characters in the string, along with that calculates the number of newline characters in the string and add the count of newline characters to the original length of the string to get the character count same as NetSuite.
For example:
let length = text.length;
let newLineCount = (text.match(/(rn|n|r)/g) || []).length;
length += newLineCount;