| 1573 | } |
| 1574 | |
| 1575 | int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) |
| 1576 | { |
| 1577 | char* buf_out = buf; |
| 1578 | const char* buf_end = buf + buf_size; |
| 1579 | while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) |
| 1580 | { |
| 1581 | unsigned int c = (unsigned int)(*in_text++); |
| 1582 | if (c < 0x80) |
| 1583 | *buf_out++ = (char)c; |
| 1584 | else |
| 1585 | buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end-buf_out-1), c); |
| 1586 | } |
| 1587 | *buf_out = 0; |
| 1588 | return (int)(buf_out - buf); |
| 1589 | } |
| 1590 | |
| 1591 | int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) |
| 1592 | { |
no test coverage detected