encode strings using dictionary