s.encode(encoding, 'replace'), to prevent UnicodeEncode errors for non-UTF8 characters