Set C locale, treat EPUB file names as UTF-8.
EPUB file names MUST be UTF-8. ASCII is a subset of UTF-8.
This commit is contained in:
parent
6c040fa951
commit
28c6c80def
@ -22,6 +22,7 @@
|
||||
#include <boost/program_options/errors.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
@ -37,6 +38,9 @@ int main(int argc, char *argv[])
|
||||
using std::cerr;
|
||||
using std::cout;
|
||||
|
||||
// locale_generator("").name.c_str() returns "*" instead of "". That's why
|
||||
// the global C locale isn't changed. So we have to set it additionally.
|
||||
std::setlocale(LC_ALL, "");
|
||||
boost::locale::generator locale_generator;
|
||||
locale_generator.add_messages_path("translations");
|
||||
locale_generator.add_messages_path("/usr/share/locale");
|
||||
|
@ -50,7 +50,7 @@ std::vector<std::string> list(const fs::path &filepath)
|
||||
std::vector<std::string> toc;
|
||||
while (archive_read_next_header(zipfile, &entry) == ARCHIVE_OK)
|
||||
{
|
||||
toc.emplace_back(archive_entry_pathname(entry));
|
||||
toc.emplace_back(archive_entry_pathname_utf8(entry));
|
||||
archive_read_data_skip(zipfile);
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,14 @@
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
SCENARIO("epubgrep::zip::list() doesn't fail and returns the right file list")
|
||||
{
|
||||
std::setlocale(LC_CTYPE, ""); // Needed for utf-8 support in libarchive.
|
||||
bool exception{false};
|
||||
std::vector<std::string> filelist;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user