// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/utils/emoji.h" #include "td/utils/base64.h" #include "td/utils/FlatHashSet.h" #include "td/utils/Gzip.h" namespace td { bool is_emoji(Slice str) { constexpr size_t MAX_EMOJI_LENGTH = 35; static const FlatHashSet emojis = [max_emoji_length = MAX_EMOJI_LENGTH] { #if TD_HAVE_ZLIB Slice packed_emojis( "eJyNndlS40q3rV-lIvbduTp983b0UGAMNriRTVONsDCmcUNnUBOxH6X2A5wVcV7gSENjYM20pPov9JGfcqY0czotyaZY609j8O1PY_B_30_" "SH8NsQ_NknG158y7b8uYk2_LmfbblzWm25c1FtqHZi7Itb8bZhmb_PNvyZifb0PQOsi1vfs-" "2vHmYbXnzKNvyZiPb8uZxtuXNZrblTWx58zTb8mYr2_" "JmO9vy5lm25c0k29AcnGVb3vyZbXnzLtvy5iTb8maUbXkzzjY0hzvZljd3sy1vNrMtb55nW968y7a8Oc-" "2vLnItrz5km158yPb8maUbWhe7GZb3jzMtrx5lG158zbb0LxsZFvebGZb3jzLtrx5nm15s5NtebOXbWhedbItb3azLW_" "2si1vTrMtbybZhub9MNvy5kW2oflwmm15s5NtWfOf640dIJftHLnsNQFKC6C0AcoZQDkHKB2A0gUoPYDSBygeQBkAuRxsApQBQHkCKHOAsgAoz" "wDlBaC8ApR3gLIEKB9ALt9PAUoLyKWxAVA2AcoWQNkGKDsAZReg7AGUfYByAFC-" "A5RDgHIEUBoA5RigNAFKDsopQGkBlDZAOQMo5wClA1C6AKUHUPoAxQMoA4AyBCgXAOUSoFwBlGuA8gOgPACUR4DyBFCmAGUGUOYAZQFQngHKC0" "B5AyjvAGUJUD4AyidACQFKBFBigJIAuRxvAJRNgLIFULYByg5A2QUoewBlH6AcAJTvAOUQoBwBlAZAOQYoTYCSg3IKUFoApQ1QzgD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77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77FT77Gtt_6p5bTQnhXa80Lb-" "ReUHGPrXfS5484_IlyND53xoTM-dMZHzvjIGR854yNnfOyMj53xsTM-dsYnzvjEGZ8447_qrT8lPr_5Vvjb4dzQHC-LHamlo_" "HL5UGAJn9hQ0NQ46DQI8WXof0fafP0IGveD7NmJ8_jI2uPVrtxRb7M_li5tYmIHv5V9KYOCe0_ot1G-yVvZ_8crP-an7bwb4SbO9_-" "P2ob96k"); static string all_emojis_str = gzdecode(base64url_decode(packed_emojis).ok()).as_slice().str(); constexpr size_t EMOJI_COUNT = 5064; #else string all_emojis_str; constexpr size_t EMOJI_COUNT = 0; #endif FlatHashSet all_emojis; all_emojis.reserve(EMOJI_COUNT); for (size_t i = 0; i < all_emojis_str.size(); i++) { CHECK(all_emojis_str[i] != ' '); CHECK(all_emojis_str[i + 1] != ' '); size_t j = i + 2; while (j < all_emojis_str.size() && all_emojis_str[j] != ' ') { j++; } CHECK(j < all_emojis_str.size()); all_emojis.insert(Slice(&all_emojis_str[i], &all_emojis_str[j])); CHECK(j - i <= max_emoji_length); i = j; } CHECK(all_emojis.size() == EMOJI_COUNT); return all_emojis; }(); auto len = str.size(); if (len > MAX_EMOJI_LENGTH + 3) { return false; } if (emojis.count(str) != 0) { return true; } if (len <= 3 || str[len - 3] != '\xEF' || str[len - 2] != '\xB8' || str[len - 1] != '\x8F') { return false; } if (len >= 6 && str[len - 6] == '\xEF' && str[len - 5] == '\xB8' && str[len - 4] == '\x8F') { return false; } return emojis.count(str.substr(0, len - 3)) != 0; } int get_fitzpatrick_modifier(Slice emoji) { if (emoji.size() < 4 || emoji[emoji.size() - 4] != '\xF0' || emoji[emoji.size() - 3] != '\x9F' || emoji[emoji.size() - 2] != '\x8F') { return 0; } auto c = static_cast(emoji.back()); if (c < 0xBB || c > 0xBF) { return 0; } return (c - 0xBB) + 2; } Slice remove_fitzpatrick_modifier(Slice emoji) { while (get_fitzpatrick_modifier(emoji) != 0) { emoji.remove_suffix(4); } return emoji; } string remove_emoji_modifiers(Slice emoji, bool remove_selectors) { string result = emoji.str(); remove_emoji_modifiers_in_place(result, remove_selectors); return result; } void remove_emoji_modifiers_in_place(string &emoji, bool remove_selectors) { static const Slice modifiers[] = {u8"\uFE0F" /* variation selector-16 */, u8"\u200D\u2640" /* zero width joiner + female sign */, u8"\u200D\u2642" /* zero width joiner + male sign */, u8"\U0001F3FB" /* emoji modifier fitzpatrick type-1-2 */, u8"\U0001F3FC" /* emoji modifier fitzpatrick type-3 */, u8"\U0001F3FD" /* emoji modifier fitzpatrick type-4 */, u8"\U0001F3FE" /* emoji modifier fitzpatrick type-5 */, u8"\U0001F3FF" /* emoji modifier fitzpatrick type-6 */}; const size_t start_index = remove_selectors ? 0 : 1; size_t j = 0; for (size_t i = 0; i < emoji.size();) { bool is_found = false; for (size_t k = start_index; k < sizeof(modifiers) / sizeof(*modifiers); k++) { auto length = modifiers[k].size(); if (i + length <= emoji.size() && Slice(&emoji[i], length) == modifiers[k]) { // skip the modifier i += length; is_found = true; break; } } if (!is_found) { emoji[j++] = emoji[i++]; } } if (j != 0) { emoji.resize(j); } } string remove_emoji_selectors(Slice emoji) { if (!is_emoji(emoji)) { return emoji.str(); } string str; for (size_t i = 0; i < emoji.size(); i++) { if (i + 3 <= emoji.size() && emoji[i] == '\xEF' && emoji[i + 1] == '\xB8' && emoji[i + 2] == '\x8F') { // skip \uFE0F i += 2; } else { str += emoji[i]; } } CHECK(is_emoji(str)); return str; } } // namespace td