mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibUnicode: Download and parse IDNA data
This commit is contained in:
parent
cfd0a60863
commit
7d9fe44039
6 changed files with 324 additions and 30 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibLocale/Locale.h>
|
||||
#include <LibUnicode/CharacterTypes.h>
|
||||
|
||||
template<class T>
|
||||
inline constexpr bool StorageTypeIsList = false;
|
||||
|
@ -598,3 +599,33 @@ ReadonlySpan<StringView> @name@()
|
|||
}
|
||||
)~~~");
|
||||
}
|
||||
|
||||
inline Vector<u32> parse_code_point_list(StringView list)
|
||||
{
|
||||
Vector<u32> code_points;
|
||||
|
||||
auto segments = list.split_view(' ');
|
||||
for (auto const& code_point : segments)
|
||||
code_points.append(AK::StringUtils::convert_to_uint_from_hex<u32>(code_point).value());
|
||||
|
||||
return code_points;
|
||||
}
|
||||
|
||||
inline Unicode::CodePointRange parse_code_point_range(StringView list)
|
||||
{
|
||||
Unicode::CodePointRange code_point_range {};
|
||||
|
||||
if (list.contains(".."sv)) {
|
||||
auto segments = list.split_view(".."sv);
|
||||
VERIFY(segments.size() == 2);
|
||||
|
||||
auto begin = AK::StringUtils::convert_to_uint_from_hex<u32>(segments[0]).value();
|
||||
auto end = AK::StringUtils::convert_to_uint_from_hex<u32>(segments[1]).value();
|
||||
code_point_range = { begin, end };
|
||||
} else {
|
||||
auto code_point = AK::StringUtils::convert_to_uint_from_hex<u32>(list).value();
|
||||
code_point_range = { code_point, code_point };
|
||||
}
|
||||
|
||||
return code_point_range;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue