mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
AK: Allow constructing a UTF-16 view from a UTF-16 string literal
UTF-16 string literals are a language-level feature. It is convenient to be able to construct a Utf16View from these strings.
This commit is contained in:
parent
e16345555b
commit
c46ba7e68d
2 changed files with 38 additions and 0 deletions
|
@ -71,6 +71,14 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
Utf16View(char16_t const (&code_units)[Size])
|
||||
: m_code_units(
|
||||
reinterpret_cast<u16 const*>(&code_units[0]),
|
||||
code_units[Size - 1] == u'\0' ? Size - 1 : Size)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(Utf16View const& other) const { return m_code_units == other.m_code_units; }
|
||||
|
||||
enum class AllowInvalidCodeUnits {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue