mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Support older compilers with missing <codecvt> header.
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
#if __has_include(<codecvt>)
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#define INDICATORS_HAVE_CODECVT 1
|
||||||
|
#endif
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -9,6 +12,7 @@
|
|||||||
|
|
||||||
namespace unicode {
|
namespace unicode {
|
||||||
|
|
||||||
|
#if INDICATORS_HAVE_CODECVT
|
||||||
namespace details {
|
namespace details {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -295,4 +299,16 @@ static inline int display_width(const std::wstring &input) {
|
|||||||
return details::mk_wcswidth(input.c_str(), input.size());
|
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
|
} // namespace unicode
|
||||||
|
|||||||
Reference in New Issue
Block a user