Cygwin: next_unicode_mbs: return full char prefix from multibyte
Convert multibyte string to wint_t string and return the length of the multibyte prefix constituting a full unicode char, taking collating elements into account. Also return the resulting wint_t string. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
c47a998d0a
commit
fbd8b4a9ad
|
@ -21,6 +21,7 @@ int is_unicode_equiv (wint_t, wint_t);
|
||||||
int is_unicode_coll_elem (const wint_t *);
|
int is_unicode_coll_elem (const wint_t *);
|
||||||
|
|
||||||
size_t next_unicode_char (wint_t *);
|
size_t next_unicode_char (wint_t *);
|
||||||
|
size_t next_unicode_mbs (wint_t *, const char *, size_t);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -1360,6 +1360,22 @@ next_unicode_char (wint_t *inp)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the number of bytes making up the next full character in inp, and
|
||||||
|
copies them over to out. This is basically next_unicode_char(), just for
|
||||||
|
multibyte input. outlen is the buffer size of the out buffer. */
|
||||||
|
extern "C" size_t
|
||||||
|
next_unicode_mbs (wint_t *out, const char *inp, size_t outlen)
|
||||||
|
{
|
||||||
|
size_t ret;
|
||||||
|
|
||||||
|
/* Max collation element is 8 wint_t's. */
|
||||||
|
ret = mbsnrtowci (out, &inp, SIZE_MAX, outlen - 1, NULL);
|
||||||
|
out[ret] = L'\0'; /* mbsnrtowci never returns -1 */
|
||||||
|
ret = next_unicode_char (out);
|
||||||
|
out[ret] = L'\0';
|
||||||
|
return wcitombs (NULL, out, 0);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
wcsxfrm_l (wchar_t *__restrict ws1, const wchar_t *__restrict ws2, size_t wsn,
|
wcsxfrm_l (wchar_t *__restrict ws1, const wchar_t *__restrict ws2, size_t wsn,
|
||||||
struct __locale_t *locale)
|
struct __locale_t *locale)
|
||||||
|
|
Loading…
Reference in New Issue