Handle utf8 and non utf8 strings