/* * returns interface description encoded in UTF-8 format */ static char *get_if_description(MIB_IFROW *pIfRow) { static wchar_t *(*mb_to_unicode)(const char *) = NULL; wchar_t *wdescr; char *utf8_descr; if (NULL == mb_to_unicode) { const OSVERSIONINFOEX *vi; /* starting with Windows Vista (Windows Server 2008) the interface description */ /* is encoded in OEM codepage while earlier versions used ANSI codepage */ if (NULL != (vi = zbx_win_getversion()) && 6 <= vi->dwMajorVersion) mb_to_unicode = zbx_oemcp_to_unicode; else mb_to_unicode = zbx_acp_to_unicode; } wdescr = mb_to_unicode(pIfRow->bDescr); utf8_descr = zbx_unicode_to_utf8(wdescr); zbx_free(wdescr); return utf8_descr; }
/* * returns interface description encoded in UTF-8 format */ static LPSTR get_if_description(MIB_IFROW *pIfRow) { static LPTSTR (*mb_to_unicode)(LPCSTR) = NULL; LPTSTR wdescr; LPSTR utf8_descr; if (NULL == mb_to_unicode) { OSVERSIONINFO version_info = {sizeof(OSVERSIONINFO)}; /* starting with Windows Vista (Windows Server 2008) the interface description */ /* is encoded in OEM codepage while earlier versions used ANSI codepage */ if (TRUE == GetVersionEx(&version_info) && 6 <= version_info.dwMajorVersion) mb_to_unicode = zbx_oemcp_to_unicode; else mb_to_unicode = zbx_acp_to_unicode; } wdescr = mb_to_unicode(pIfRow->bDescr); utf8_descr = zbx_unicode_to_utf8(wdescr); zbx_free(wdescr); return utf8_descr; }