Internals: Added ImTextCountUtf8BytesFromChar() helper.
This commit is contained in:
parent
ac39c4b2a8
commit
bb2de30e3e
@ -1479,6 +1479,13 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
|
||||
}
|
||||
}
|
||||
|
||||
// Not optimal but we very rarely use this function.
|
||||
int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end)
|
||||
{
|
||||
unsigned int dummy = 0;
|
||||
return ImTextCharFromUtf8(&dummy, in_text, in_text_end);
|
||||
}
|
||||
|
||||
static inline int ImTextCountUtf8BytesFromChar(unsigned int c)
|
||||
{
|
||||
if (c < 0x80) return 1;
|
||||
|
@ -107,10 +107,11 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
||||
|
||||
// Helpers: UTF-8 <> wchar
|
||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count
|
||||
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
||||
IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
||||
IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
|
||||
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points
|
||||
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
||||
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
||||
|
||||
// Helpers: Misc
|
||||
IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
|
||||
|
Loading…
Reference in New Issue
Block a user