Only do unicode scans of string when needed

Previously the unicode character <-> byte translation would occur even
if the string did not contain any unicode characters.

Now it only performs the translation when the string length is different
than the UTF8 string length.