try encode with 'replace' to work around extended char issues