now works for both utf-8 and ISO8859-1