Encode UTF-8 strings safely. Refs #2786

Assumes esmith::db layer returns strings marked as UTF-8.