Skip to content

Fix for stricter encoding names in latest MicroPython: UTF-8 → utf-8 - #40

Open
oliver-joos wants to merge 1 commit into
cbrand:mainfrom
oliver-joos:use-stricter-encoding-names
Open

Fix for stricter encoding names in latest MicroPython: UTF-8 → utf-8#40
oliver-joos wants to merge 1 commit into
cbrand:mainfrom
oliver-joos:use-stricter-encoding-names

Conversation

@oliver-joos

@oliver-joos oliver-joos commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Since some commits were merged on 2026-07-20 MicroPython treats encoding names more strict:
Now only "utf-8", "utf8" or "ascii" are valid - lower-case!

micropython/micropython@11d002be
micropython/micropython@a62626a5
micropython/micropython@ba9ea94 ← docs and tests

This bug will cause a LookupError at runtime with latest MicroPython:

>>> "test".encode("UTF-8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown encoding: UTF-8
>>> "test".encode("utf-8")
b'test'

This fix won't break compatibility to older MicroPython versions.

Since commit micropython/micropython@11d002be and following (2026-07-20)
MicroPython treats encoding names more strict: only "utf-8", "utf8" or "ascii" are valid, lower-case!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant