Merge pull request #65 from godbyk/feature/workaround-missing-codecvt

Support older compilers with missing <codecvt> header.
This commit is contained in:
Pranav
2020-06-17 08:35:13 -05:00
committed by GitHub

View File

@@ -1,7 +1,10 @@
#pragma once
#include <clocale>
#if __has_include(<codecvt>)
#include <codecvt>
#define INDICATORS_HAVE_CODECVT 1
#endif
#include <cstdlib>
#include <locale>
#include <string>
@@ -9,6 +12,7 @@
namespace unicode {
#if INDICATORS_HAVE_CODECVT
namespace details {
/*
@@ -295,4 +299,16 @@ static inline int display_width(const std::wstring &input) {
return details::mk_wcswidth(input.c_str(), input.size());
}
#else
static inline int display_width(const std::string &input) {
return input.length();
}
static inline int display_width(const std::wstring &input) {
return input.length();
}
#endif
} // namespace unicode