105 if (radical_stroke_table !=
nullptr &&
106 !DecodeRadicalTable(radical_stroke_table, &radical_map))
121 int hangul_offset = unicharset.
size();
127 int han_offset = hangul_offset + kTotalJamos;
128 for (
int u = 0; u <= unicharset.
size(); ++u) {
131 if (u == unicharset.
size() && u != null_id)
break;
134 std::vector<char32> unicodes;
136 if (u < unicharset.
size())
138 if (u < unicharset.
size() &&
141 int unicode = unicodes[0];
142 int leading, vowel, trailing;
143 auto it = radical_map.find(unicode);
144 if (it != radical_map.end()) {
146 int num_radicals = it->second->size();
147 for (
int c = 0; c < num_radicals; ++c) {
148 code.Set(c, han_offset + (*it->second)[c]);
150 int pre_hash = RadicalPreHash(*it->second);
151 int num_samples = radical_counts[pre_hash]++;
153 code.Set(num_radicals, han_offset + num_samples +
kRadicalRadix);
157 code.Set3(leading + hangul_offset, vowel +
kLCount + hangul_offset,
162 if (code.length() == 0) {
172 for (
int i = 0; i < unicodes.size(); ++i) {
173 int position = code.length();
175 tprintf(
"Unichar %d=%s is too long to encode!!\n", u,
179 int uni = unicodes[i];
180 UNICHAR unichar(uni);
181 char* utf8 = unichar.utf8_str();
186 if (direct_set.
size() >
189 tprintf(
"Code space expanded from original unicharset!!\n");
195 encoder_.push_back(code);
202 for (
int u = 0; u < unicharset.
size(); ++u) {
203 RecodedCharID* code = &encoder_[u];
204 if (code->length() <= i)
continue;
205 max_offset = std::max(max_offset, (*code)(i)-han_offset);
206 code->Set(i, (*code)(i) + code_offset);
208 if (max_offset == 0)
break;
209 code_offset += max_offset + 1;
211 DefragmentCodeValues(null_id >= 0 ? 1 : -1);
static const int kMaxCodeLen
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
void unichar_insert(const char *const unichar_repr, OldUncleanUnichars old_style)
bool contains_unichar(const char *const unichar_repr) const
DLLSYM void tprintf(const char *format,...)
std::unordered_map< int, int > RSCounts
static std::string CleanupString(const char *utf8_str)
static std::vector< char32 > UTF8ToUTF32(const char *utf8_str)
static bool DecomposeHangul(int unicode, int *leading, int *vowel, int *trailing)
const char * id_to_unichar(UNICHAR_ID id) const
std::unordered_map< int, std::unique_ptr< std::vector< int > >> RSMap
bool has_special_codes() const