Skip to content

str.center() bug with unicode characters #17827

@faerot

Description

@faerot

Port, board and/or hardware

Raspberry Pico; Linux PC

MicroPython version

MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico W with RP2040
MicroPython v1.22.1+ds-1build2 on 2024-04-01; linux [GCC 13.2.0]

Reproduction

Run this code in REPL or separately:
print(len('°'.center(4)))

Expected behaviour

Expected to output 4

Observed behaviour

Outputs 3

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunicodeBugs and enhancements related to Unicode/UTF-8 support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions