diff --git a/log.c b/log.c index d9c2d136c..98a2370f6 100644 --- a/log.c +++ b/log.c @@ -62,7 +62,12 @@ static void *log_handler_ctx; extern char *__progname; +#ifdef WINDOWS +#define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL|VIS_LOG_UTF16) +#else #define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL) +#endif + #define LOG_STDERR_VIS (VIS_SAFE|VIS_OCTAL) /* textual representation of log-facilities/levels */ diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index 0e04ed025..40cb0a80f 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c @@ -114,6 +114,16 @@ vis(char *dst, int c, int flag, int nextc) goto done; } } + +#ifdef WINDOWS + /*Avoid encoding UTF-16 chatacters so they + show up correctly in the logs*/ + if (flag & VIS_LOG_UTF16) { + *dst++ = c; + goto done; + } +#endif + if (((c & 0177) == ' ') || (flag & VIS_OCTAL) || ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) { *dst++ = '\\'; diff --git a/openbsd-compat/vis.h b/openbsd-compat/vis.h index 2cdfd364b..7c4d9b043 100644 --- a/openbsd-compat/vis.h +++ b/openbsd-compat/vis.h @@ -81,6 +81,13 @@ */ #define UNVIS_END 1 /* no more characters */ +#ifdef WINDOWS +/* + * UTF16 logs + */ +#define VIS_LOG_UTF16 0x800 +#endif + char *vis(char *, int, int, int); int strvis(char *, const char *, int); int stravis(char **, const char *, int);