Fix handling of non-UTF8 strings.