summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llstring.cpp106
-rw-r--r--indra/llcommon/llstring.h7
2 files changed, 113 insertions, 0 deletions
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index f6629803ee..9a2251e0a7 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -600,6 +600,7 @@ std::string mbcsstring_makeASCII(const std::string& wstr)
}
return out_str;
}
+
std::string utf8str_removeCRLF(const std::string& utf8str)
{
if (0 == utf8str.length())
@@ -621,6 +622,43 @@ std::string utf8str_removeCRLF(const std::string& utf8str)
return out;
}
+// Search for any emoji symbol, return true if found
+bool wstring_has_emoji(const LLWString& wstr)
+{
+ for (const llwchar& wch : wstr)
+ {
+ if (LLStringOps::isEmoji(wch))
+ return true;
+ }
+
+ return false;
+}
+
+// Cut emoji symbols if exist
+bool wstring_remove_emojis(LLWString& wstr)
+{
+ bool found = false;
+ for (size_t i = 0; i < wstr.size(); ++i)
+ {
+ if (LLStringOps::isEmoji(wstr[i]))
+ {
+ wstr.erase(i--, 1);
+ found = true;
+ }
+ }
+ return found;
+}
+
+// Cut emoji symbols if exist
+bool utf8str_remove_emojis(std::string& utf8str)
+{
+ LLWString wstr = utf8str_to_wstring(utf8str);
+ if (!wstring_remove_emojis(wstr))
+ return false;
+ utf8str = wstring_to_utf8str(wstr);
+ return true;
+}
+
#if LL_WINDOWS
unsigned int ll_wstring_default_code_page()
{
@@ -833,6 +871,66 @@ std::string LLStringOps::sDayFormat;
std::string LLStringOps::sAM;
std::string LLStringOps::sPM;
+// static
+bool LLStringOps::isEmoji(llwchar wch)
+{
+ // Most of the following symbols are not actually emoticons, but rather small pictures
+
+ // 0x1F000 .. 0x1F02F - mahjong tiles
+ // https://symbl.cc/en/unicode/table/#mahjong-tiles
+
+ // 0x1F030 .. 0x1F09F - domino tiles
+ // https://symbl.cc/en/unicode/table/#domino-tiles
+
+ // 0x1F0A0 .. 0x1F0FF - playing cards
+ // https://symbl.cc/en/unicode/table/#playing-cards
+
+ // 0x1F100 .. 0x1F1FF - enclosed alphanumeric supplement
+ // https://symbl.cc/en/unicode/table/#enclosed-alphanumeric-supplement
+
+ // 0x1F200 .. 0x1F2FF - enclosed ideographic supplement
+ // https://symbl.cc/en/unicode/table/#enclosed-ideographic-supplement
+
+ // 0x1F300 .. 0x1F5FF - miscellaneous symbols and pictographs
+ // https://symbl.cc/en/unicode/table/#miscellaneous-symbols-and-pictographs
+
+ // 0x1F600 .. 0x1F64F - emoticons
+ // https://symbl.cc/en/unicode/table/#emoticons
+
+ // 0x1F650 .. 0x1F67F - ornamental dingbats
+ // https://symbl.cc/en/unicode/table/#ornamental-dingbats
+
+ // 0x1F680 .. 0x1F6FF - transport and map symbols
+ // https://symbl.cc/en/unicode/table/#transport-and-map-symbols
+
+ // 0x1F700 .. 0x1F77F - alchemical symbols
+ // https://symbl.cc/en/unicode/table/#alchemical-symbols
+
+ // 0x1F780 .. 0x1F7FF - geometric shapes extended
+ // https://symbl.cc/en/unicode/table/#geometric-shapes-extended
+
+ // 0x1F800 .. 0x1F8FF - supplemental arrows c
+ // https://symbl.cc/en/unicode/table/#supplemental-arrows-c
+
+ // 0x1F900 .. 0x1F9FF - supplemental symbols and pictographs
+ // https://symbl.cc/en/unicode/table/#supplemental-symbols-and-pictographs
+
+ // 0x1FA00 .. 0x1FA6F - chess symbols
+ // https://symbl.cc/en/unicode/table/#chess-symbols
+
+ // 0x1FA70 .. 0x1FAFF - symbols and pictographs extended a
+ // https://symbl.cc/en/unicode/table/#symbols-and-pictographs-extended-a
+
+ // 0x1FB00 .. 0x1FBFF - symbols for legacy computing
+ // https://symbl.cc/en/unicode/table/#symbols-for-legacy-computing
+
+ // 0x1FC00 .. 0x1FFFF - undefined block 44
+ // These symbols aren't defined yet
+ // https://symbl.cc/en/unicode/table/#undefined-block-44
+
+ return wch >= 0x1F000 && wch < 0x1FC00;
+}
+
S32 LLStringOps::collate(const llwchar* a, const llwchar* b)
{
@@ -1235,9 +1333,17 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token,
}
else
{
+#if 0
+ // EXT-1565 : Zai Lynch, James Linden : 15/Oct/09
+ // [BSI] Feedback: Viewer clock mentions SLT, but would prefer it to show PST/PDT
// "slt" = Second Life Time, which is deprecated.
// If not utc or user local time, fallback to Pacific time
replacement = LLStringOps::getPacificDaylightTime() ? "PDT" : "PST";
+#else
+ // SL-20370 : Steeltoe Linden : 29/Sep/23
+ // Change "PDT" to "SLT" on menu bar
+ replacement = "SLT";
+#endif
}
return true;
}
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 1fd6cac14a..6e70a6fa5c 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -189,6 +189,8 @@ public:
static bool isAlnum(char a) { return isalnum((unsigned char)a) != 0; }
static bool isAlnum(llwchar a) { return iswalnum(a) != 0; }
+ static bool isEmoji(llwchar wch);
+
static S32 collate(const char* a, const char* b) { return strcoll(a, b); }
static S32 collate(const llwchar* a, const llwchar* b);
@@ -737,6 +739,11 @@ LL_COMMON_API std::string mbcsstring_makeASCII(const std::string& str);
LL_COMMON_API std::string utf8str_removeCRLF(const std::string& utf8str);
+LL_COMMON_API bool wstring_has_emoji(const LLWString& wstr);
+
+LL_COMMON_API bool wstring_remove_emojis(LLWString& wstr);
+
+LL_COMMON_API bool utf8str_remove_emojis(std::string& utf8str);
#if LL_WINDOWS
/* @name Windows string helpers