Skip to content

Commit

Permalink
SL-19801 Log unicode characters for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
LLGuru committed Nov 30, 2023
1 parent 337b2fc commit 2fad5a7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
24 changes: 24 additions & 0 deletions indra/llcommon/llstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions indra/llcommon/llstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions indra/llui/lltexteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p

void LLTextEditor::insertEmoji(llwchar emoji)
{
LL_INFOS() << "LLTextEditor::insertEmoji(" << wchar_utf8_preview(emoji) << ")" << LL_ENDL;
auto styleParams = LLStyle::Params();
styleParams.font = LLFontGL::getFontEmoji();
auto segment = new LLEmojiTextSegment(new LLStyle(styleParams), mCursorPos, mCursorPos + 1, *this);
Expand Down
2 changes: 1 addition & 1 deletion indra/llui/llview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
handled = handleUnicodeCharHere(uni_char);
if (handled && LLView::sDebugKeys)
{
LL_INFOS() << "Unicode key handled by " << getName() << LL_ENDL;
LL_INFOS() << "Unicode key " << wchar_utf8_preview(uni_char) << " is handled by " << getName() << LL_ENDL;
}
}
}
Expand Down

0 comments on commit 2fad5a7

Please sign in to comment.