summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-11-30 13:59:14 +0100
committerGuru <alexandrgproductengine@lindenlab.com>2023-11-30 14:08:29 +0100
commit2fad5a770b3583e576992d075c24bc0e25443053 (patch)
treeff1e1704392a077741e01d7cf4522f7b9eb9e5ed /indra/llcommon
parent337b2fcc3605ef00d0338b1588c2ec86c265fd68 (diff)
SL-19801 Log unicode characters for debug
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llstring.cpp24
-rw-r--r--indra/llcommon/llstring.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index d68cbaa22c..81b0207038 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -365,6 +365,30 @@ S32 wchar_utf8_length(const llwchar wc)
}
}
+std::string wchar_utf8_preview(const llwchar wc)
+{
+ std::ostringstream oss;
+ oss << std::hex << std::uppercase << (U32)wc;
+
+ U8 out_bytes[8];
+ U32 size = (U32)wchar_to_utf8chars(wc, (char*)out_bytes);
+
+ if (size > 1)
+ {
+ oss << " [";
+ for (U32 i = 0; i < size; ++i)
+ {
+ if (i)
+ {
+ oss << ", ";
+ }
+ oss << (int)out_bytes[i];
+ }
+ oss << "]";
+ }
+
+ return oss.str();
+}
S32 wstring_utf8_length(const LLWString& wstr)
{
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 62403969e4..8def59ed7f 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -682,6 +682,8 @@ LL_COMMON_API S32 wstring_utf8_length(const LLWString& wstr);
// Length in bytes of this wide char in a UTF8 string
LL_COMMON_API S32 wchar_utf8_length(const llwchar wc);
+LL_COMMON_API std::string wchar_utf8_preview(const llwchar wc);
+
LL_COMMON_API std::string utf8str_tolower(const std::string& utf8str);
// Length in llwchar (UTF-32) of the first len units (16 bits) of the given UTF-16 string.