mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:57:49 +00:00
AK: Add StringBuilder::append_codepoint(u32)
Also, implement append(Utf32View) using it.
This commit is contained in:
parent
0bc92c259d
commit
d4bbc00901
2 changed files with 25 additions and 19 deletions
|
@ -113,10 +113,8 @@ void StringBuilder::clear()
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringBuilder::append(const Utf32View& utf32_view)
|
void StringBuilder::append_codepoint(u32 codepoint)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < utf32_view.length(); ++i) {
|
|
||||||
auto codepoint = utf32_view.codepoints()[i];
|
|
||||||
if (codepoint <= 0x7f) {
|
if (codepoint <= 0x7f) {
|
||||||
append((char)codepoint);
|
append((char)codepoint);
|
||||||
} else if (codepoint <= 0x07ff) {
|
} else if (codepoint <= 0x07ff) {
|
||||||
|
@ -136,6 +134,13 @@ void StringBuilder::append(const Utf32View& utf32_view)
|
||||||
append(0xbf);
|
append(0xbf);
|
||||||
append(0xbd);
|
append(0xbd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StringBuilder::append(const Utf32View& utf32_view)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < utf32_view.length(); ++i) {
|
||||||
|
auto codepoint = utf32_view.codepoints()[i];
|
||||||
|
append_codepoint(codepoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
void append(const StringView&);
|
void append(const StringView&);
|
||||||
void append(const Utf32View&);
|
void append(const Utf32View&);
|
||||||
void append(char);
|
void append(char);
|
||||||
|
void append_codepoint(u32);
|
||||||
void append(const char*, size_t);
|
void append(const char*, size_t);
|
||||||
void appendf(const char*, ...);
|
void appendf(const char*, ...);
|
||||||
void appendvf(const char*, va_list);
|
void appendvf(const char*, va_list);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue