.. _invalid-unicode-codec:

invalid-unicode-codec / E2501
=============================

**Message emitted:**

UTF-16 and UTF-32 aren't backward compatible. Use UTF-8 instead

**Description:**

*For compatibility use UTF-8 instead of UTF-16/UTF-32. See also https://bugs.python.org/issue1503789 for a history of this issue. And https://softwareengineering.stackexchange.com/questions/102205/should-utf-16-be-considered-harmful for some possible problems when using UTF-16 for instance.*


**Correct code:**

.. literalinclude:: /data/messages/i/invalid-unicode-codec/good.py
   :language: python

**Additional details:**

You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !


Created by the `unicode_checker <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/unicode.py>`__ checker.