Decoding and encoding text