Caveat emptor: snprintf() is not per se available on Windows.  If it's aliased as _snprintf(), then it doesn't zero-terminate the buffer on overflow...

In node and a couple of other places, I use this shim:

```c
#ifdef _WIN32
// emulate snprintf() on windows, _snprintf() doesn't zero-terminate the buffer
// on overflow...
#include <stdarg.h>
inline static int snprintf(char* buf, unsigned int len, const char* fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  int n = _vsprintf_p(buf, len, fmt, ap);
  if (len)
    buf[len - 1] = '\0';
  va_end(ap);
  return n;
}
#endif
```

It's not great, it could check `max(0, min(n, len))` but it suffices for most things.