4 #include <unordered_map>
9 #include "unicode/uchar.h"
10 #include "unicode/uscript.h"
42 std::vector<std::vector<char32>>*
dest) {
44 std::vector<std::vector<char32>> graphemes;
59 std::unique_ptr<Validator> validator(
61 for (
const auto& grapheme : graphemes) {
62 if (!validator->ValidateCleanAndSegmentInternal(g_mode, grapheme,
dest)) {
75 return std::unique_ptr<Validator>(
78 return std::unique_ptr<Validator>(
81 return std::unique_ptr<Validator>(
84 return std::unique_ptr<Validator>(
87 return std::unique_ptr<Validator>(
99 std::vector<std::vector<char32>>*
dest) {
115 std::vector<std::vector<char32>>*
dest) {
126 dest->push_back(std::vector<char32>());
135 static bool CmpPairSecond(
const std::pair<int, int>& p1,
136 const std::pair<int, int>& p2) {
137 return p1.second < p2.second;
144 const std::vector<char32>& utf32) {
145 std::unordered_map<int, int> histogram;
152 UScriptCode script_code = uscript_getScript(ch, err);
154 script_code != USCRIPT_COMMON) ||
155 script_code == USCRIPT_MYANMAR) {
156 if (script_code == USCRIPT_MYANMAR)
161 if (!histogram.empty()) {
163 std::max_element(histogram.begin(), histogram.end(), CmpPairSecond)
172 return static_cast<ViramaScript>(codebase);
182 (unicode & 0x7f) == 0x4d) ||
192 return (0x1cd0 <= unicode && unicode < 0x1d00) ||
193 (0xa8e0 <= unicode && unicode <= 0xa8f7) ||
194 (0x951 <= unicode && unicode <= 0x954);
207 codes_.reserve(text.size());