-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnicodeProperty.hpp
45 lines (35 loc) · 980 Bytes
/
UnicodeProperty.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <Siv3D.hpp>
#include <unicode/uchar.h>
#include <unicode/brkiter.h>
#include <unicode/errorcode.h>
namespace tomolatoon
{
namespace Unicode
{
namespace Property
{
template <class GetType, UProperty PropertyIndex>
GetType GetProperty(char32 ch)
{
return static_cast<GetType>(u_getIntPropertyValue(ch, PropertyIndex));
}
template <class GetType>
GetType GetProperty(char32 ch, UProperty propIndex)
{
return static_cast<GetType>(u_getIntPropertyValue(ch, propIndex));
}
ULineBreak GetLineBreak(char32 ch)
{
return GetProperty<ULineBreak, UCHAR_LINE_BREAK>(ch);
}
String GetUnicodeName(char32 c)
{
char buffer[100];
icu::ErrorCode errorCode;
size_t size = u_charName(c, U_UNICODE_CHAR_NAME, buffer, std::ranges::size(buffer), errorCode);
return s3d::Unicode::FromUTF8({buffer, size});
}
} // namespace Property
} // namespace Unicode
} // namespace tomolatoon