From c927cbddc52d3b68f6703cfe8336357b6a47b693 Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Thu, 25 Sep 2025 11:15:59 -0400 Subject: [PATCH] System/Libraries/String: Add String.Lower() --- System/Libraries/String.HC | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/System/Libraries/String.HC b/System/Libraries/String.HC index 6ec1e65..7667d32 100644 --- a/System/Libraries/String.HC +++ b/System/Libraries/String.HC @@ -60,6 +60,20 @@ Bool @string_ends_with(U8* fragment, U8* str) return !MemCmp(fragment, str + StrLen(str) - StrLen(fragment), StrLen(fragment)); } +U0 @string_lower(U8* s) +{ + while (*s) { + switch (*s) { + case 'A' ... 'Z': + *s += 32; + break; + default: + break; + } + ++s; + } +} + U8* @string_replace(U8* s, U8* oldW, U8* newW) { if (!StrFind(oldW, s)) { @@ -163,6 +177,7 @@ class @string Bool (*BeginsWith)(U8* fragment, U8* str); Bool (*EndsWith)(U8* fragment, U8* str); Bool (*IsNumber)(U8* s); + U0 (*Lower)(U8* s); U8* (*Replace)(U8* s, U8* oldW, U8* newW); U8** (*Split)(U8* s, U8 ch = '\n', I64 * cnt); U0 (*Trim)(U8* s, U8 ch = NULL, I64 mode = TRIM_BOTH); @@ -173,6 +188,7 @@ String.Append = &@string_append; String.BeginsWith = &@string_begins_with; String.EndsWith = &@string_ends_with; String.IsNumber = &@string_is_number; +String.Lower = &@string_lower; String.Replace = &@string_replace; String.Split = &@string_split; String.Trim = &@string_trim;