Documentation

Init.Data.String.Length

@[extern lean_string_length]

Returns the length of a string in Unicode code points.

Examples:

Equations
Instances For
    @[deprecated String.length_toList (since := "2025-10-30")]
    @[deprecated String.length_ofList (since := "2025-10-30")]
    @[simp]
    @[simp]
    @[simp]
    theorem String.length_push {s : String} (c : Char) :
    (s.push c).length = s.length + 1
    @[simp]
    theorem String.length_pushn {s : String} (c : Char) (n : Nat) :
    (s.pushn c n).length = s.length + n
    @[simp]
    theorem String.length_append (s t : String) :
    (s ++ t).length = s.length + t.length
    @[deprecated String.length_singleton (since := "2026-02-12")]