Given charAt(), charCodeAt()and codePointAt(), I found a mismatch between what the parameter means. Before I really thought about this, I thought you would always be safe to access the character at length-1. But I read the difference between charCodeAt () and codePointAt () that charCodeAt () refers to 16-bit (byte pairs), so besides reading i, you will also need i+1if they are surrogate pairs (like the methodology with UTF-16) . While codePointAt () needs a parameter that refers to the character position of UTF-8 (based on zero). So now I am having difficulty regarding whether it counts the lengthnumber of characters or the number of byte pairs of UTF-16. I believe JavaScript contains strings like UTF-16, but usinglength-1 from a line in a line with a large number of 4-byte characters using the function codePointAt()will not be at the end of the line !!
source
share