Gets the length of an array or string. In a string, a UTF-16 surrogate pair counts as a single position.