Log UTF-16 characters properly (#500)

This commit is contained in:
vthiebaut10 2021-04-23 13:15:45 -04:00 committed by GitHub
parent 904ffd36d4
commit cd1e7d6f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

5
log.c
View File

@ -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 */

View File

@ -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++ = '\\';

View File

@ -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);