From 0fddc74a3f9add47841124b4d77b097f4646d14f Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 30 Oct 2022 01:05:45 +0200 Subject: compiler: fix support for non-utf8 terminals The compiler echoes the names of the files being processed. Those file names may contain UTF-8 characters. However, some consoles may not support those. This is notably the case of the Windows CMD or on Linux with the legacy C locale. This caused the following error: ldgallery: : commitBuffer: invalid argument (invalid character) This patch adds automatic transliteration when a non-UTF8 terminal is detected, so that neither the compiler or the terminal crash due to UTF8 characters. GitHub: closes #341 --- compiler/app/Main.hs | 5 +++-- compiler/package.yaml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'compiler') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index 3e6f254..a9630ce 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -1,7 +1,7 @@ -- ldgallery - A static generator which turns a collection of tagged -- pictures into a searchable web gallery. -- --- Copyright (C) 2019-2021 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2022 Pacien TRAN-GIRARD -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as @@ -28,6 +28,7 @@ import Data.Aeson (ToJSON) import System.FilePath (()) import System.Directory (canonicalizePath, listDirectory) import System.Console.CmdArgs +import Main.Utf8 (withUtf8) import Compiler import Files (readDirectory, copyTo, remove) @@ -103,7 +104,7 @@ options = Options main :: IO () main = - do + withUtf8 $ do opts <- cmdArgs options buildGallery opts deployViewer opts diff --git a/compiler/package.yaml b/compiler/package.yaml index 7bd86e9..0c07efe 100644 --- a/compiler/package.yaml +++ b/compiler/package.yaml @@ -4,7 +4,7 @@ homepage: https://ldgallery.pacien.org github: "pacien/ldgallery" license: AGPL-3 author: "Pacien TRAN-GIRARD, Guillaume FOUET" -copyright: "2019-2021 Pacien TRAN-GIRARD, Guillaume FOUET" +copyright: "2019-2022 Pacien TRAN-GIRARD, Guillaume FOUET" extra-source-files: - readme.md @@ -29,6 +29,7 @@ dependencies: - safe - time - process +- with-utf8 default-extensions: - DuplicateRecordFields -- cgit v1.2.3