MCPcopy Create free account
hub / github.com/Wemino/EchoPatch / DebugTextEncoding

Method DebugTextEncoding

include/imgui/imgui.cpp:16229–16265  ·  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

16227
16228// Helper tool to diagnose between text encoding issues and font loading issues. Pass your UTF-8 string and verify that there are correct.
16229void ImGui::DebugTextEncoding(const char* str)
16230{
16231 Text("Text: \"%s\"", str);
16232 if (!BeginTable("##DebugTextEncoding", 4, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable))
16233 return;
16234 TableSetupColumn("Offset");
16235 TableSetupColumn("UTF-8");
16236 TableSetupColumn("Glyph");
16237 TableSetupColumn("Codepoint");
16238 TableHeadersRow();
16239 const char* str_end = str + strlen(str); // As we may receive malformed UTF-8, pass an explicit end instead of relying on ImTextCharFromUtf8() assuming enough space.
16240 for (const char* p = str; *p != 0; )
16241 {
16242 unsigned int c;
16243 const int c_utf8_len = ImTextCharFromUtf8(&c, p, str_end);
16244 TableNextColumn();
16245 Text("%d", (int)(p - str));
16246 TableNextColumn();
16247 for (int byte_index = 0; byte_index < c_utf8_len; byte_index++)
16248 {
16249 if (byte_index > 0)
16250 SameLine();
16251 Text("0x%02X", (int)(unsigned char)p[byte_index]);
16252 }
16253 TableNextColumn();
16254 TextUnformatted(p, p + c_utf8_len);
16255 if (!GetFont()->IsGlyphInFont((ImWchar)c))
16256 {
16257 SameLine();
16258 TextUnformatted("[missing]");
16259 }
16260 TableNextColumn();
16261 Text("U+%04X", (int)c);
16262 p += c_utf8_len;
16263 }
16264 EndTable();
16265}
16266
16267static void DebugFlashStyleColorStop()
16268{

Callers

nothing calls this directly

Calls 2

ImTextCharFromUtf8Function · 0.85
IsGlyphInFontMethod · 0.80

Tested by

no test coverage detected