Check to see if String object responds to encode before attempting

Supports older versions of Ruby.