33 #ifndef COMMON_WINDOWS_STRING_UTILS_INL_H__ 34 #define COMMON_WINDOWS_STRING_UTILS_INL_H__ 46 #if _MSC_VER >= 1400 // MSVC 2005/8 47 #define WIN_STRING_FORMAT_LL "ll" 48 #else // MSC_VER >= 1400 49 #define WIN_STRING_FORMAT_LL "I64" 50 #endif // MSC_VER >= 1400 57 #if _MSC_VER < 1400 // MSVC 2005/8 58 #define swprintf _snwprintf 62 #define swprintf swprintf_s 63 #endif // MSC_VER < 1400 75 static void safe_wcscpy(
wchar_t *destination,
size_t destination_size,
76 const wchar_t *source);
82 static void safe_wcsncpy(
wchar_t *destination,
size_t destination_size,
83 const wchar_t *source,
size_t count);
94 static wstring
GetBaseName(
const wstring &filename);
106 size_t destination_size,
107 const wchar_t *source) {
108 #if _MSC_VER >= 1400 // MSVC 2005/8 109 wcscpy_s(destination, destination_size, source);
110 #else // _MSC_VER >= 1400 114 wcsncpy(destination, source, destination_size);
115 if (destination && destination_size)
116 destination[destination_size - 1] = 0;
117 #endif // _MSC_VER >= 1400 122 size_t destination_size,
123 const wchar_t *source,
125 #if _MSC_VER >= 1400 // MSVC 2005/8 126 wcsncpy_s(destination, destination_size, source, count);
127 #else // _MSC_VER >= 1400 131 if (destination_size < count)
132 count = destination_size;
134 wcsncpy(destination, source, count);
135 if (destination && count)
136 destination[count - 1] = 0;
137 #endif // _MSC_VER >= 1400 142 #endif // COMMON_WINDOWS_STRING_UTILS_INL_H__ static void safe_wcsncpy(wchar_t *destination, size_t destination_size, const wchar_t *source, size_t count)
static void safe_wcscpy(wchar_t *destination, size_t destination_size, const wchar_t *source)
static wstring GetBaseName(const wstring &filename)
static bool safe_wcstombs(const wstring &wcs, string *mbs)
static bool safe_mbstowcs(const string &mbs, wstring *wcs)