mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
AK: Implement StringBuilder::append_as_lowercase(char ch)
This patch adds a convenience method to AK::StringBuilder which converts ASCII uppercase characters to lowercase before appending them.
This commit is contained in:
parent
df29d58e19
commit
f51b0729f5
Notes:
sideshowbarker
2024-07-18 17:48:56 +09:00
Author: https://github.com/MaxWipfli
Commit: f51b0729f5
Pull-request: https://github.com/SerenityOS/serenity/pull/7055
Issue: https://github.com/SerenityOS/serenity/issues/6910
Reviewed-by: https://github.com/Dexesttp
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/linusg
2 changed files with 9 additions and 0 deletions
|
@ -120,6 +120,14 @@ void StringBuilder::append(const Utf32View& utf32_view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringBuilder::append_as_lowercase(char ch)
|
||||||
|
{
|
||||||
|
if (ch >= 'A' && ch <= 'Z')
|
||||||
|
append(ch + 0x20);
|
||||||
|
else
|
||||||
|
append(ch);
|
||||||
|
}
|
||||||
|
|
||||||
void StringBuilder::append_escaped_for_json(const StringView& string)
|
void StringBuilder::append_escaped_for_json(const StringView& string)
|
||||||
{
|
{
|
||||||
for (auto ch : string) {
|
for (auto ch : string) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
void append(const char*, size_t);
|
void append(const char*, size_t);
|
||||||
void appendvf(const char*, va_list);
|
void appendvf(const char*, va_list);
|
||||||
|
|
||||||
|
void append_as_lowercase(char);
|
||||||
void append_escaped_for_json(const StringView&);
|
void append_escaped_for_json(const StringView&);
|
||||||
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue