remove debug-output
reverse order of checks to fix > two byte utf-8 encoding
support surrogate pairs