#include "strutils.h"
#include "widechar.h"
-#ifdef HAVE_WIDECHAR
/* Replace non printable chars.
Note \t and \n etc. are non printable.
Return 1 if replacement made, 0 otherwise. */
*/
size_t mbs_safe_nwidth(const char *buf, size_t bufsz, size_t *sz)
{
- mbstate_t st;
const char *p = buf, *last = buf;
size_t width = 0, bytes = 0;
+#ifdef HAVE_WIDECHAR
+ mbstate_t st;
memset(&st, 0, sizeof(st));
-
+#endif
if (p && *p && bufsz)
last = p + (bufsz - 1);
*/
char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf)
{
- mbstate_t st;
const char *p = s;
char *r;
size_t sz = s ? strlen(s) : 0;
+#ifdef HAVE_WIDECHAR
+ mbstate_t st;
+ memset(&st, 0, sizeof(st));
+#endif
if (!sz || !buf)
return NULL;
- memset(&st, 0, sizeof(st));
-
r = buf;
*width = 0;
r += 4;
*width += 4;
} else {
- width++;
+ (*width)++;
*r++ = *p;
}
} else if (!iswprint(wc)) {
*width += 4;
} else {
*r++ = *p++;
- *width++;
+ (*width)++;
}
#endif
}
*r = '\0';
-
return buf;
}
return mbs_safe_encode_to_buffer(s, width, buf);
}
+#ifdef HAVE_WIDECHAR
+
static bool
wc_ensure_printable (wchar_t *wchars)
{
return ret;
}
-#endif
+#endif /* HAVE_WIDECHAR */
/* Truncate multi-byte string to @width and returns number of
* bytes of the new string @str, and in @width returns number