Fix bug for text encoding.