Fix for non-utf-8 string handling