Set locale globally.

This commit is contained in:
tastytea 2019-05-22 12:25:06 +02:00
parent 7bfb3c7e07
commit f94d6a2229
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 9 additions and 12 deletions

View File

@ -124,20 +124,14 @@ void export_adoc(const vector<Database::entry> &entries, ostream &out)
}
else
{ // Sort by tag names otherwise.
std::locale loc("");
std::locale loc;
const std::collate<char> &coll =
std::use_facet<std::collate<char>>(loc);
if (coll.compare(a.first.data(), a.first.data()
+ a.first.length(),
b.first.data(), b.first.data()
+ b.first.length()) == -1)
{ // -1 == less than
return true;
}
else
{
return false;
}
return (coll.compare(
a.first.data(), a.first.data()
+ a.first.length(),
b.first.data(), b.first.data()
+ b.first.length()) == -1);
}
});

View File

@ -19,6 +19,7 @@
#include <chrono>
#include <fstream>
#include <memory>
#include <locale>
#include "sqlite.hpp"
#include "parse_options.hpp"
#include "uri.hpp"
@ -33,6 +34,8 @@ using std::chrono::system_clock;
int main(const int argc, const char *argv[])
{
std::locale::global(std::locale("")); // Set locale globally.
options opts = parse_options(argc, argv);
if (opts.status_code != 0)
{