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
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user