encode string before sending