#include "utils.h" #include #include std::string formatCentAsEuroString(const int cent, int width) { std::stringstream currStream; try { std::locale myLocale("de_DE.utf8"); currStream.imbue(myLocale); currStream << std::right << std::setw(width) << std::showbase << std::put_money(cent, false); } catch (std::runtime_error& err) { currStream << std::fixed << std::setw(width) << std::setprecision(2) << cent / 100.0L << " €"; } return currStream.str(); }