tdlight/tdutils/td/utils/emoji.cpp

303 lines
22 KiB
C++
Raw Normal View History

2021-09-20 21:30:23 +02:00
//
2022-12-31 22:28:08 +01:00
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
2021-09-20 21:30:23 +02:00
//
// 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"
2022-03-11 19:38:48 +01:00
#include "td/utils/FlatHashSet.h"
#include "td/utils/Gzip.h"
2021-09-20 21:30:23 +02:00
namespace td {
bool is_emoji(Slice str) {
constexpr size_t MAX_EMOJI_LENGTH = 35;
2022-03-11 19:38:48 +01:00
static const FlatHashSet<Slice, SliceHash> emojis = [max_emoji_length = MAX_EMOJI_LENGTH] {
#if TD_HAVE_ZLIB
Slice packed_emojis(
2022-09-27 13:28:08 +02:00
"eJyNnety27i2rV8lVfvf-XXul7frVmfZ6cS6kJJskrLj7tUUaYmOI1uObcUEWLUfJecBdledFzgaJIfJiUkyqyqAJ4wxJzE_QABF2fGPs-"
"jdj7PVux_TzbFsjyU7lttj2R3L_t2PC3Ms9t2PYHEsy3c_wg_H8vuxfDyWT8dydizjY5kcy_RYZsfiHYt_LPNjKd79iI5foz-P5Rg_"
"OsaPjjGjY8zV-2P5x7EcfVfH-Ktj_-rhWI7XXX07lu_HctReHjWXx-tdHq93efPux9XxmldHn6tj3Kuj39VxXFcX7358Pn79fH4ssI_j_"
"3y89u0xt9vLdz--HMf1Zfnu7-tf3h-r36bH6mSCykPlo5qjWqCC7uQc1QWqAFWIKjpWH35FVVpfUT2g2qN6RPUN1ROqF1QHVN-P1e8zVLja2S-"
"oEOVshOo3VBjV2T9QnaA6RfUB1e-oPqL6hOoM1RgVRn-GPM4Q-ayMjDzOkMcZ8jhDHmfI4wx5nCGPM-RxhtEfZ_"
"1YXaK6QvUZ1TWqP1B9QXWHClme7VDdo0K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9DvWvZ9y35o2c7_EV_7NO17p_3gtJ3_8Lzxzx3_3PHPHX_j-BvH3zj-xvG3jr91_K3jbx3_wvEvHP_C8S9a_"
"puW76blt2n5bNp6h_fG4b1xeG8c3huH98bhvXF4bxzeG4f3xuG9cXhvHN4bh_fG4b1xeG8c3huH98bhvXF4byRv_reFu5Z937IfWrbz_"
"wrWPpJ3u_3gtJ3_JK_xzx3_3PHPHX_j-BvH3zj-xvG3jr91_K3jbx3_wvEvHP_C8X_jzT8Ys1i_a_2FmKpVmptDu-"
"PYOnqXv2EdpaVZ9Rxb1e5U9v19ffah1clm-aOMwR8ts_KZfUDrdgVzWQ3sO-yk-XZ52ly9b5n1Zvhrqb8o_6vSX3m5i5uqN7grmz56g2-"
"Vjf9uLHiqRiXsetut_-PO9-_-P_-VKLY");
static string all_emojis_str = gzdecode(base64url_decode(packed_emojis).ok()).as_slice().str();
2022-09-27 13:28:08 +02:00
constexpr size_t EMOJI_COUNT = 4713;
#else
string all_emojis_str;
constexpr size_t EMOJI_COUNT = 0;
#endif
2022-03-11 19:38:48 +01:00
FlatHashSet<Slice, SliceHash> 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]));
2022-01-31 20:00:00 +01:00
CHECK(j - i <= max_emoji_length);
i = j;
}
CHECK(all_emojis.size() == EMOJI_COUNT);
return all_emojis;
}();
if (str.size() > MAX_EMOJI_LENGTH) {
2021-09-20 21:30:23 +02:00
return false;
}
return emojis.count(str) != 0;
}
2021-10-05 15:12:04 +02:00
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<unsigned char>(emoji.back());
if (c < 0xBB || c > 0xBF) {
return 0;
}
return (c - 0xBB) + 2;
}
2021-10-05 22:20:49 +02:00
Slice remove_fitzpatrick_modifier(Slice emoji) {
while (get_fitzpatrick_modifier(emoji) != 0) {
emoji.remove_suffix(4);
}
return emoji;
}
string remove_emoji_modifiers(Slice emoji) {
string result = emoji.str();
remove_emoji_modifiers_in_place(result);
return result;
}
void remove_emoji_modifiers_in_place(string &emoji) {
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 */};
size_t j = 0;
for (size_t i = 0; i < emoji.size();) {
bool is_found = false;
for (auto &modifier : modifiers) {
auto length = modifier.size();
if (i + length <= emoji.size() && Slice(&emoji[i], length) == modifier) {
// skip modifier
i += length;
is_found = true;
break;
}
}
if (!is_found) {
emoji[j++] = emoji[i++];
}
}
2022-11-11 20:20:38 +01:00
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;
}
2021-09-20 21:30:23 +02:00
} // namespace td