1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Changed ImTextCharToUtf8() to return bytes count rather than original pointer. (#8820)

Amend c2bf4abfa1
This commit is contained in:
ocornut 2025-07-22 14:06:44 +09:00
parent 3401dbde92
commit ed5bd1f9ef
3 changed files with 12 additions and 7 deletions

View file

@ -2582,11 +2582,11 @@ static inline int ImTextCharToUtf8_inline(char* buf, int buf_size, unsigned int
return 0;
}
const char* ImTextCharToUtf8(char out_buf[5], unsigned int c)
int ImTextCharToUtf8(char out_buf[5], unsigned int c)
{
int count = ImTextCharToUtf8_inline(out_buf, 5, c);
out_buf[count] = 0;
return out_buf;
return count;
}
// Not optimal but we very rarely use this function.
@ -16922,8 +16922,10 @@ void ImGui::DebugNodeFont(ImFont* font)
#endif
char c_str[5];
Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar);
Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar);
ImTextCharToUtf8(c_str, font->FallbackChar);
Text("Fallback character: '%s' (U+%04X)", c_str, font->FallbackChar);
ImTextCharToUtf8(c_str, font->EllipsisChar);
Text("Ellipsis character: '%s' (U+%04X)", c_str, font->EllipsisChar);
for (int src_n = 0; src_n < font->Sources.Size; src_n++)
{
@ -16965,7 +16967,10 @@ void ImGui::DebugNodeFont(ImFont* font)
{
char utf8_buf[5];
for (unsigned int n = c; n < c_end; n++)
BulletText("Codepoint U+%04X (%s)", n, ImTextCharToUtf8(utf8_buf, n));
{
ImTextCharToUtf8(utf8_buf, n);
BulletText("Codepoint U+%04X (%s)", n, utf8_buf);
}
TreePop();
}
TableNextColumn();