Patent attributes
Techniques for improving encoding and decoding data are described herein. According to one embodiment, in response to a symbol retrieved from an input stream having a sequence of symbols, it is determined whether a current context can encode the retrieved symbol. A code representing an escape down token in the current context is emitted to a code stream if the current context cannot encode the retrieved symbol. A code representing the retrieved symbol in the current context is emitted to the code stream if the current context can encode the retrieved symbol. Optionally, the current context is escaped to a context having a higher order by emitting a code representing an escape up token in the code stream, where a higher order context is a child context to a lower order context as a parent context.