util.string.fold

Shared

Applies full Unicode case folding for caseless comparisons


Syntax

local result = util.string.fold(
    input
)

Parameters

TypeNameDescription
string | intinputString to fold, or a single codepoint

Returns

TypeNameDescription
string | intresultCase-folded string, or the folded codepoint if input was a number

Examples

Fold a string for caseless comparison
local result = util.string.fold("HELLO")

core.engine.print("info", result) -- 'hello'
Compare two strings caselessly across scripts
local a = util.string.fold("Straße")
local b = util.string.fold("STRASSE")

core.engine.print("info", a == b) -- true
Use fold instead of lower for non-Latin scripts
local result = util.string.fold("İstanbul")

core.engine.print("info", result) -- folds 'İ' correctly, unlike a plain lower()

On this page