From 18c49d3d02072ccec1fab922b3d842fb76bfb7c2 Mon Sep 17 00:00:00 2001 From: Otavio Pontes Date: Fri, 16 Nov 2018 22:12:21 +0000 Subject: [PATCH] locale: Set locale to system locale Standard locale on C applications is C and we use in clearlinux UTF-8 for file names. Libarchive checks the program locale to convert filenames so we need to set this. According to setlocale documentation, setlocale(LC_ALL, "") sets the locale to system default (in the case of ClearLinux, UTF-8). More information on the libarchive problem: https://github.com/libarchive/libarchive/wiki/Filenames and https://github.com/libarchive/libarchive/issues/587 Fixes #445 Signed-off-by: Otavio Pontes --- src/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.c b/src/main.c index da6dcbed..30340356 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE // for basename() #include +#include #include #include #include @@ -157,6 +158,12 @@ int main(int argc, char **argv) int index; int ret; + /* Set locale to system locale + * Change from the standard (C) to system locale, so libarchive can + * handle filename conversions. + * More information on the libarchive problem: + * https://github.com/libarchive/libarchive/wiki/Filenames */ + setlocale(LC_ALL, ""); if (parse_options(argc, argv, &index) < 0) { return EINVALID_OPTION; }