Encode characters for database look up the right way.