mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
AK: Stop using ShortString in String::from_code_point
Refactor it to use StringBase::replace_with_new_short_string instead.
This commit is contained in:
parent
dcd1fda9c8
commit
7506736869
2 changed files with 20 additions and 7 deletions
|
@ -12,6 +12,19 @@
|
|||
|
||||
namespace AK::UnicodeUtils {
|
||||
|
||||
constexpr int bytes_to_store_code_point_in_utf8(u32 code_point)
|
||||
{
|
||||
if (code_point <= 0x7f)
|
||||
return 1;
|
||||
if (code_point <= 0x7ff)
|
||||
return 2;
|
||||
if (code_point <= 0xffff)
|
||||
return 3;
|
||||
if (code_point <= 0x10ffff)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
[[nodiscard]] constexpr int code_point_to_utf8(u32 code_point, Callback callback)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue