Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

str.casefold

Produces a Unicode case-folded string for caseless comparison.

Version: Python 3.14; repository image, production runtime not attested

Syntax

s.casefold()

Produces a Unicode case-folded string for caseless comparison.

A fold can expand a character into several letters, so folded indices need not match original indices.

Both Straße and STRASSE fold to strasse. The character after the sharp s moves to a different offset. To highlight a match in the original string, keep a mapping back to source positions.

Examples

print("Straße".casefold())
print("Straße".casefold() == "STRASSE".casefold())

Result

strasse
True

Both Straße and STRASSE fold to strasse. The character after the sharp s moves to a different offset. To highlight a match in the original string, keep a mapping back to source positions.

Sources