Encode string for Javascript