mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Merge branch 'obsd-master'
This commit is contained in:
22
utf8.c
22
utf8.c
@ -449,6 +449,28 @@ utf8_towc(const struct utf8_data *ud, wchar_t *wc)
|
||||
return (UTF8_DONE);
|
||||
}
|
||||
|
||||
/* Convert wide character to UTF-8 character. */
|
||||
enum utf8_state
|
||||
utf8_fromwc(wchar_t wc, struct utf8_data *ud)
|
||||
{
|
||||
int size, width;
|
||||
|
||||
size = wctomb(ud->data, wc);
|
||||
if (size < 0) {
|
||||
log_debug("UTF-8 %d, wctomb() %d", wc, errno);
|
||||
wctomb(NULL, 0);
|
||||
return (UTF8_ERROR);
|
||||
}
|
||||
if (size == 0)
|
||||
return (UTF8_ERROR);
|
||||
ud->size = ud->have = size;
|
||||
if (utf8_width(ud, &width) == UTF8_DONE) {
|
||||
ud->width = width;
|
||||
return (UTF8_DONE);
|
||||
}
|
||||
return (UTF8_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open UTF-8 sequence.
|
||||
*
|
||||
|
Reference in New Issue
Block a user