Encode/decode character type