Right now that function has a special case for length <= 1, when it returns the passed length as is, disregarding a potential case of single partial surrogate code unit. To handle this, the user has to either special case length <= 1 and call validate_utf16_with_errors(), and then use the returned .count value; or simply call validate_utf16_with_errors() right away and get the length from that. This makes that function kinda useless.
I haven't done an exhaustive testing, but from a quick glance at the code, the utf8 variant handles single-character strings properly.
Right now that function has a special case for length <= 1, when it returns the passed length as is, disregarding a potential case of single partial surrogate code unit. To handle this, the user has to either special case length <= 1 and call
validate_utf16_with_errors(), and then use the returned.countvalue; or simply callvalidate_utf16_with_errors()right away and get the length from that. This makes that function kinda useless.I haven't done an exhaustive testing, but from a quick glance at the code, the
utf8variant handles single-character strings properly.