| 176 | } |
| 177 | |
| 178 | static std::unordered_map<std::string, uint8_t> unicode_utf8_to_byte_map() { |
| 179 | std::unordered_map<std::string, uint8_t> map; |
| 180 | for (int ch = 0x21; ch <= 0x7E; ++ch) { // u'!' to u'~' |
| 181 | assert(0 <= ch && ch < 256); |
| 182 | map[unicode_cpt_to_utf8(ch)] = ch; |
| 183 | } |
| 184 | for (int ch = 0xA1; ch <= 0xAC; ++ch) { // u'¡' to u'¬' |
| 185 | assert(0 <= ch && ch < 256); |
| 186 | map[unicode_cpt_to_utf8(ch)] = ch; |
| 187 | } |
| 188 | for (int ch = 0xAE; ch <= 0xFF; ++ch) { // u'®' to u'ÿ' |
| 189 | assert(0 <= ch && ch < 256); |
| 190 | map[unicode_cpt_to_utf8(ch)] = ch; |
| 191 | } |
| 192 | auto n = 0; |
| 193 | for (int ch = 0; ch < 256; ++ch) { |
| 194 | if (map.find(unicode_cpt_to_utf8(ch)) == map.end()) { |
| 195 | map[unicode_cpt_to_utf8(256 + n)] = ch; |
| 196 | ++n; |
| 197 | } |
| 198 | } |
| 199 | return map; |
| 200 | } |
| 201 | |
| 202 | static inline std::wstring unicode_wstring_from_utf8(const std::string & s) { |
| 203 | #if defined(__clang__) |
no test coverage detected