Skip to content

Commit

Permalink
Workaround for missing lconv support in android
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Panteleev committed May 17, 2016
1 parent d00b43c commit 7e970c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <cstdio>
#include <cstring>
#include <limits>
#include <locale>
#include <memory>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -2778,7 +2779,9 @@ void BasicWriter<Char>::write_int(T value, Spec spec) {
}
case 'n': {
unsigned num_digits = internal::count_digits(abs_value);
fmt::StringRef sep = std::localeconv()->thousands_sep;
// locale c++ API may be just stubbed on Android, but it compiles at least
char sep_char = std::use_facet<std::numpunct<char> >(std::locale(std::setlocale(LC_ALL, NULL))).thousands_sep();
fmt::StringRef sep(&char_sep, 1);
unsigned size = static_cast<unsigned>(
num_digits + sep.size() * (num_digits - 1) / 3);
CharPtr p = prepare_int_buffer(size, spec, prefix, prefix_size) + 1;
Expand Down

0 comments on commit 7e970c3

Please sign in to comment.