Add the SPDLOG_USE_WCHAR tweak to enable support for Unicode names on Windows. Refs #111

This commit is contained in:
unknown
2016-04-02 22:12:43 -05:00
parent 139b1bd094
commit 113ebcfd97
7 changed files with 104 additions and 48 deletions

View File

@@ -11,6 +11,11 @@
#include <memory>
#include <exception>
#if defined(_WIN32) && defined(SPDLOG_USE_WCHAR)
#include <codecvt>
#include <locale>
#endif
//visual studio does not support noexcept yet
#ifndef _MSC_VER
#define SPDLOG_NOEXCEPT noexcept
@@ -95,4 +100,25 @@ private:
};
#if defined(_WIN32) && defined(SPDLOG_USE_WCHAR)
#define SPDLOG_FILENAME_T(s) L ## s
typedef std::wstring filename_str_t;
typedef wchar_t filename_char_t;
inline std::string filename_to_bytes(const filename_str_t& filename)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> c;
return c.to_bytes(filename);
}
#else
#define SPDLOG_FILENAME_T(s) s
typedef std::string filename_str_t;
typedef char filename_char_t;
inline std::string filename_to_bytes(const filename_str_t& filename)
{
return filename;
}
#endif
} //spdlog