With a little bit more work, you could have something you could pass to codecs.register()¹, so that you could encode and decode in the standard way:<p><pre><code>    text = u&#x27;ႹЄLᒪo, ǃ&#x27;
    enc = text.encode(&#x27;utf-9&#x27;)
    dec = enc.decode(&#x27;utf-9&#x27;)
    assert text == dec
</code></pre>
¹: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;2.7&#x2F;library&#x2F;codecs.html#codecs.register" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;2.7&#x2F;library&#x2F;codecs.html#codecs.regis...</a>