Add UTF-8 types

This commit is contained in:
Victor Zverovich
2018-07-21 09:13:21 -07:00
parent d778bded95
commit 2a4e948864
6 changed files with 92 additions and 11 deletions

View File

@@ -202,6 +202,16 @@ class locale {
std::locale get() { return locale_; }
};
FMT_FUNC size_t internal::count_code_points(u8string_view s) {
const char8_t *data = s.data();
int num_code_points = 0;
for (size_t i = 0, size = s.size(); i != size; ++i) {
if ((data[i].value & 0xc0) != 0x80)
++num_code_points;
}
return num_code_points;
}
template <typename Char>
FMT_FUNC Char internal::thousands_sep(locale_provider *lp) {
std::locale loc = lp ? lp->locale().get() : std::locale();