mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
AK: Replace C-style casts
This commit is contained in:
parent
7d6908d9a5
commit
067d0689c5
14 changed files with 49 additions and 49 deletions
|
@ -16,22 +16,22 @@ template<typename Callback>
|
|||
[[nodiscard]] constexpr int code_point_to_utf8(u32 code_point, Callback callback)
|
||||
{
|
||||
if (code_point <= 0x7f) {
|
||||
callback((char)code_point);
|
||||
callback(static_cast<char>(code_point));
|
||||
return 1;
|
||||
} else if (code_point <= 0x07ff) {
|
||||
callback((char)(((code_point >> 6) & 0x1f) | 0xc0));
|
||||
callback((char)(((code_point >> 0) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 6) & 0x1f) | 0xc0));
|
||||
callback(static_cast<char>(((code_point >> 0) & 0x3f) | 0x80));
|
||||
return 2;
|
||||
} else if (code_point <= 0xffff) {
|
||||
callback((char)(((code_point >> 12) & 0x0f) | 0xe0));
|
||||
callback((char)(((code_point >> 6) & 0x3f) | 0x80));
|
||||
callback((char)(((code_point >> 0) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 12) & 0x0f) | 0xe0));
|
||||
callback(static_cast<char>(((code_point >> 6) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 0) & 0x3f) | 0x80));
|
||||
return 3;
|
||||
} else if (code_point <= 0x10ffff) {
|
||||
callback((char)(((code_point >> 18) & 0x07) | 0xf0));
|
||||
callback((char)(((code_point >> 12) & 0x3f) | 0x80));
|
||||
callback((char)(((code_point >> 6) & 0x3f) | 0x80));
|
||||
callback((char)(((code_point >> 0) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 18) & 0x07) | 0xf0));
|
||||
callback(static_cast<char>(((code_point >> 12) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 6) & 0x3f) | 0x80));
|
||||
callback(static_cast<char>(((code_point >> 0) & 0x3f) | 0x80));
|
||||
return 4;
|
||||
}
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue