Interpret the string as the decimal representation of a natural number.
Panics if the string is not a string of digits.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[extern lean_string_validate_utf8]
Returns true if the given byte array consists of valid UTF-8.
Equations
- String.validateUTF8 a = (String.validateUTF8.loop a 0).isSome
Instances For
Equations
- String.validateUTF8.loop a i = if i < a.size then do let c ← String.utf8DecodeChar? a i String.validateUTF8.loop a (i + String.csize c) else pure ()
Instances For
@[extern lean_string_from_utf8]
Converts a UTF-8 encoded ByteArray
string to String
.
Equations
- String.fromUTF8 a h = String.fromUTF8.loop a 0 ""
Instances For
Equations
- String.fromUTF8.loop a i acc = if i < a.size then let c := (String.utf8DecodeChar? a i).getD default; String.fromUTF8.loop a (i + String.csize c) (acc.push c) else acc
Instances For
@[inline]
Converts a UTF-8 encoded ByteArray
string to String
,
or returns none
if a
is not properly UTF-8 encoded.
Equations
- String.fromUTF8? a = if h : String.validateUTF8 a = true then some (String.fromUTF8 a h) else none
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]
@[extern lean_string_to_utf8]
Converts the given String
to a UTF-8 encoded byte array.
Equations
- a.toUTF8 = { data := { data := a.data.bind String.utf8EncodeChar } }
Instances For
@[specialize #[]]
Advance the given iterator until the predicate returns true or the end of the string is reached.
Equations
Instances For
@[specialize #[]]
def
String.Iterator.foldUntil
{α : Type u_1}
(it : String.Iterator)
(init : α)
(f : α → Char → Option α)
:
Equations
Instances For
Equations
- s.removeLeadingSpaces = let n := String.findLeadingSpacesSize s; if (n == 0) = true then s else String.removeNumLeadingSpaces n s