MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / DebugTextEncoding

Method DebugTextEncoding

KBotExt/imgui/imgui.cpp:13563–13596  ·  view source on GitHub ↗

Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.

Source from the content-addressed store, hash-verified

13561
13562// Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.
13563void ImGui::DebugTextEncoding(const char* str)
13564{
13565 Text("Text: \"%s\"", str);
13566 if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
13567 return;
13568 TableSetupColumn("Offset");
13569 TableSetupColumn("UTF-8");
13570 TableSetupColumn("Glyph");
13571 TableSetupColumn("Codepoint");
13572 TableHeadersRow();
13573 for (const char* p = str; *p != 0; )
13574 {
13575 unsigned int c;
13576 const int c_utf8_len = ImTextCharFromUtf8(&c, p, NULL);
13577 TableNextColumn();
13578 Text("%d", (int)(p - str));
13579 TableNextColumn();
13580 for (int byte_index = 0; byte_index < c_utf8_len; byte_index++)
13581 {
13582 if (byte_index > 0)
13583 SameLine();
13584 Text("0x%02X", (int)(unsigned char)p[byte_index]);
13585 }
13586 TableNextColumn();
13587 if (GetFont()->FindGlyphNoFallback((ImWchar)c))
13588 TextUnformatted(p, p + c_utf8_len);
13589 else
13590 TextUnformatted((c == IM_UNICODE_CODEPOINT_INVALID) ? "[invalid]" : "[missing]");
13591 TableNextColumn();
13592 Text("U+%04X", (int)c);
13593 p += c_utf8_len;
13594 }
13595 EndTable();
13596}
13597
13598// Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds.
13599static void MetricsHelpMarker(const char* desc)

Callers

nothing calls this directly

Calls 2

ImTextCharFromUtf8Function · 0.85
FindGlyphNoFallbackMethod · 0.80

Tested by

no test coverage detected