Maybe instead of a global, you could make a ``utf7`` tuple with state information inside it (including the "dialect data" and the decoding buffer), then use them when decoding from the tuple?