Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stream.imbue to set/unset current locale in table_internal.hpp #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions include/tabulate/table_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ inline void Printer::print_row_in_cell(std::ostream &stream, TableInternal &tabl
auto cell = table[index.first][index.second];
auto locale = cell.locale();
auto is_multi_byte_character_support_enabled = cell.is_multi_byte_character_support_enabled();
auto old_locale = std::locale::global(std::locale(locale));
auto old_locale = std::locale();
stream.imbue(std::locale(locale));
auto format = cell.format();
auto text_height = splitted_cell_text.size();
auto padding_top = *format.padding_top_;
Expand Down Expand Up @@ -377,7 +378,7 @@ inline void Printer::print_row_in_cell(std::ostream &stream, TableInternal &tabl
reset_element_style(stream);
}
}
std::locale::global(old_locale);
stream.imbue(old_locale);
}

inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table,
Expand All @@ -386,7 +387,8 @@ inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &
size_t num_columns) {
auto cell = table[index.first][index.second];
auto locale = cell.locale();
auto old_locale = std::locale::global(std::locale(locale));
auto old_locale = std::locale();
stream.imbue(std::locale(locale));
auto format = cell.format();
auto column_width = dimension.second;

Expand Down Expand Up @@ -439,7 +441,7 @@ inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &
stream << corner;
reset_element_style(stream);
}
std::locale::global(old_locale);
stream.imbue(old_locale);
return true;
}

Expand All @@ -449,7 +451,8 @@ inline bool Printer::print_cell_border_bottom(std::ostream &stream, TableInterna
size_t num_columns) {
auto cell = table[index.first][index.second];
auto locale = cell.locale();
auto old_locale = std::locale::global(std::locale(locale));
auto old_locale = std::locale();
stream.imbue(std::locale(locale));
auto format = cell.format();
auto column_width = dimension.second;

Expand Down Expand Up @@ -482,7 +485,7 @@ inline bool Printer::print_cell_border_bottom(std::ostream &stream, TableInterna
stream << corner;
reset_element_style(stream);
}
std::locale::global(old_locale);
stream.imbue(old_locale);
return true;
}

Expand Down