if (bad_wide_buf_len != -1)
retval += bad_wide_buf_len;
+ else
+ retval++;
free(bad_wide_buf);
} else {
free(bad_wide_buf);
- retval += bad_wide_buf_len;
+ if (bad_wide_buf_len != -1)
+ retval += bad_wide_buf_len;
+ else
+ retval++;
} else
#endif
retval += wide_buf_len;
wide_buf = control_rep((unsigned char)wide_buf);
#ifdef NANO_WIDE
- if (!ISSET(NO_UTF8))
+ if (!ISSET(NO_UTF8)) {
ctrl_wide_buf_len = wctomb(ctrl_wide_buf,
(wchar_t)wide_buf);
- else {
+
+ if (ctrl_wide_buf_len == -1) {
+ ctrl_wide_buf_len = 1;
+ ctrl_wide_buf[0] = ' ';
+ }
+ } else {
#endif
ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = (unsigned char)wide_buf;
wide_buf = control_rep((unsigned char)wide_buf);
#ifdef NANO_WIDE
- if (!ISSET(NO_UTF8))
+ if (!ISSET(NO_UTF8)) {
ctrl_wide_buf_len = wctomb(ctrl_wide_buf,
(wchar_t)wide_buf);
- else {
+
+ if (ctrl_wide_buf_len == -1) {
+ ctrl_wide_buf_len = 1;
+ ctrl_wide_buf[0] = ' ';
+ }
+ } else {
#endif
ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = (unsigned char)wide_buf;
bad_wide_buf_len = wctomb(bad_wide_buf,
(wchar_t)wide_buf);
+ if (bad_wide_buf_len == -1) {
+ bad_wide_buf_len = 1;
+ bad_wide_buf[0] = ' ';
+ }
+
for (i = 0; i < bad_wide_buf_len; i++)
converted[index++] = bad_wide_buf[i];