Assume UTF8 encoding and remove illegal chars, if on Ruby >= 1.9