Given an NFKD-normalized string, returns a set of all strings which are normalized into the same `nfkd`. `norm2orig` is the normalized to un-normalized character mapping.
| 96 | // normalized into the same `nfkd`. `norm2orig` is the normalized to |
| 97 | // un-normalized character mapping. |
| 98 | std::vector<Builder::Chars> ExpandUnnormalized( |
| 99 | const Builder::Chars &nfkd, |
| 100 | const std::map<char32, std::set<char32>> &norm2orig) { |
| 101 | CHECK(!nfkd.empty()); |
| 102 | std::vector<Builder::Chars> results; |
| 103 | for (const auto c : port::FindOrDie(norm2orig, nfkd[0])) { |
| 104 | results.push_back({c}); |
| 105 | } |
| 106 | for (size_t i = 1; i < nfkd.size(); ++i) { |
| 107 | const auto &orig = port::FindOrDie(norm2orig, nfkd[i]); |
| 108 | std::vector<Builder::Chars> new_results; |
| 109 | for (const auto &r : results) { |
| 110 | for (const auto c : orig) { |
| 111 | new_results.emplace_back(r); |
| 112 | new_results.back().push_back(c); |
| 113 | } |
| 114 | } |
| 115 | results = std::move(new_results); |
| 116 | } |
| 117 | CHECK_EQ(nfkd.size(), results[0].size()); |
| 118 | return results; |
| 119 | } |
| 120 | #endif // ENABLE_NFKC_COMPILE |
| 121 | |
| 122 | // Normalizes `src` with `chars_map` and returns normalized Chars. |
no test coverage detected