Skip to content

Instantly share code, notes, and snippets.

@lutter
Created January 11, 2016 23:36
Show Gist options
  • Save lutter/b3929c6b9052bd7164a4 to your computer and use it in GitHub Desktop.
Save lutter/b3929c6b9052bd7164a4 to your computer and use it in GitHub Desktop.
#include <locale>
#include <boost/locale.hpp>
int main() {
boost::locale::generator gen;
std::locale loc = gen("");
std::string lang = std::use_facet<boost::locale::info>(loc).language();
std::string country = std::use_facet<boost::locale::info>(loc).country();
std::cout << "Locale: " << loc.name() << std::endl;
std::cout << "Lang: " << lang << std::endl;
std::cout << "Country: " << country << std::endl;
return 0;
}
/* Compile with
opt/pl-build-tools/bin/g++ -std=c++11 -o loc -I /opt/pl-build-tools/include/ \
-L /opt/pl-build-tools/lib -lboost_locale \
-Wl,-rpath="/opt/pl-build-tools/lib" loc.cc
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment