Encode characters