| 1610 | } |
| 1611 | |
| 1612 | int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) |
| 1613 | { |
| 1614 | ImWchar* buf_out = buf; |
| 1615 | ImWchar* buf_end = buf + buf_size; |
| 1616 | while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) |
| 1617 | { |
| 1618 | unsigned int c; |
| 1619 | in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); |
| 1620 | if (c == 0) |
| 1621 | break; |
| 1622 | if (c <= IM_UNICODE_CODEPOINT_MAX) // FIXME: Losing characters that don't fit in 2 bytes |
| 1623 | *buf_out++ = (ImWchar)c; |
| 1624 | } |
| 1625 | *buf_out = 0; |
| 1626 | if (in_text_remaining) |
| 1627 | *in_text_remaining = in_text; |
| 1628 | return (int)(buf_out - buf); |
| 1629 | } |
| 1630 | |
| 1631 | int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) |
| 1632 | { |
no test coverage detected