i18n: always read and write UTF-8, ignoring current locale (#34)
Also remove a bunch of CPP conditions. Uses the GHC-version-independent UTF-8 layer from pandoc.
This commit is contained in:
		
							parent
							
								
									ce4347a2be
								
							
						
					
					
						commit
						6a845eb5e4
					
				| @ -17,15 +17,13 @@ import Data.List | ||||
| import Safe (readDef) | ||||
| import System.Console.GetOpt | ||||
| import System.Exit (exitFailure) | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import System.IO.UTF8 (putStr, putStrLn) | ||||
| #endif | ||||
| 
 | ||||
| import Hledger.Cli.Options | ||||
| import Hledger.Cli.Utils (withJournalDo) | ||||
| import Hledger.Cli.Version (progversionstr, binaryfilename) | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import Hledger.Data.UTF8 (putStr, putStrLn) | ||||
| 
 | ||||
| 
 | ||||
| progname_chart = progname_cli ++ "-chart" | ||||
|  | ||||
| @ -2,7 +2,8 @@ | ||||
| 
 | ||||
| The Hledger.Data library allows parsing and querying of C++ ledger-style | ||||
| journal files.  It generally provides a compatible subset of C++ ledger's | ||||
| functionality.  This package re-exports all the Hledger.Data.* modules. | ||||
| functionality.  This package re-exports all the Hledger.Data.* modules | ||||
| (except UTF8, which requires an explicit import.) | ||||
| 
 | ||||
| -} | ||||
| 
 | ||||
|  | ||||
| @ -19,6 +19,7 @@ module Data.Time.Calendar, | ||||
| module Data.Time.LocalTime, | ||||
| module Debug.Trace, | ||||
| module Hledger.Data.Utils, | ||||
| -- module Hledger.Data.UTF8, | ||||
| module Text.Printf, | ||||
| module Text.RegexPR, | ||||
| module Test.HUnit, | ||||
| @ -36,10 +37,9 @@ import Data.Time.Clock | ||||
| import Data.Time.Calendar | ||||
| import Data.Time.LocalTime | ||||
| import Debug.Trace | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (readFile,putStr,print) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| -- needs to be done in each module I think | ||||
| -- import Prelude hiding (readFile,writeFile,getContents,putStr,putStrLn) | ||||
| -- import Hledger.Data.UTF8 | ||||
| import Test.HUnit | ||||
| import Text.Printf | ||||
| import Text.RegexPR | ||||
|  | ||||
| @ -16,13 +16,6 @@ module Hledger.Read ( | ||||
|        myTimelog, | ||||
| ) | ||||
| where | ||||
| import Hledger.Data.Dates (getCurrentDay) | ||||
| import Hledger.Data.Types (Journal(..), Reader(..)) | ||||
| import Hledger.Data.Journal (nullctx) | ||||
| import Hledger.Data.Utils | ||||
| import Hledger.Read.JournalReader as JournalReader | ||||
| import Hledger.Read.TimelogReader as TimelogReader | ||||
| 
 | ||||
| import Control.Monad.Error | ||||
| import Data.Either (partitionEithers) | ||||
| import Safe (headDef) | ||||
| @ -30,12 +23,15 @@ import System.Directory (doesFileExist, getHomeDirectory) | ||||
| import System.Environment (getEnv) | ||||
| import System.FilePath ((</>)) | ||||
| import System.IO (IOMode(..), withFile, stderr) | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| 
 | ||||
| import Hledger.Data.Dates (getCurrentDay) | ||||
| import Hledger.Data.Types (Journal(..), Reader(..)) | ||||
| import Hledger.Data.Journal (nullctx) | ||||
| import Hledger.Data.Utils | ||||
| import Prelude hiding (getContents) | ||||
| import System.IO.UTF8 (getContents, hGetContents) | ||||
| #else | ||||
| import System.IO (hGetContents) | ||||
| #endif | ||||
| import Hledger.Data.UTF8 (getContents, hGetContents) | ||||
| import Hledger.Read.JournalReader as JournalReader | ||||
| import Hledger.Read.TimelogReader as TimelogReader | ||||
| 
 | ||||
| 
 | ||||
| journalenvvar           = "LEDGER_FILE" | ||||
|  | ||||
| @ -121,12 +121,10 @@ import Control.Monad.Error (ErrorT(..), throwError, catchError) | ||||
| import Data.List.Split (wordsBy) | ||||
| import Safe (headDef) | ||||
| import Text.ParserCombinators.Parsec hiding (parse) | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (readFile, putStr, putStrLn, print, getContents) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| 
 | ||||
| import Hledger.Data | ||||
| import Prelude hiding (readFile) | ||||
| import Hledger.Data.UTF8 (readFile) | ||||
| import Hledger.Read.Utils | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -42,12 +42,14 @@ library | ||||
|                   Hledger.Data.TimeLog | ||||
|                   Hledger.Data.Types | ||||
|                   Hledger.Data.Utils | ||||
|                   Hledger.Data.UTF8 | ||||
|                   Hledger.Read | ||||
|                   Hledger.Read.Utils | ||||
|                   Hledger.Read.JournalReader | ||||
|                   Hledger.Read.TimelogReader | ||||
|   Build-Depends: | ||||
|                   base >= 3 && < 5 | ||||
|                  ,bytestring | ||||
|                  ,containers | ||||
|                  ,directory | ||||
|                  ,filepath | ||||
|  | ||||
| @ -7,10 +7,6 @@ Released under GPL version 3 or later. | ||||
| 
 | ||||
| module Hledger.Vty.Main where | ||||
| 
 | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import System.IO.UTF8 (putStr, putStrLn) | ||||
| #endif | ||||
| import Graphics.Vty | ||||
| import Safe (headDef) | ||||
| import System.Console.GetOpt | ||||
| @ -22,6 +18,8 @@ import Hledger.Cli.Register | ||||
| import Hledger.Cli.Utils (withJournalDo) | ||||
| import Hledger.Cli.Version (progversionstr, binaryfilename) | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import Hledger.Data.UTF8 (putStr, putStrLn) | ||||
| 
 | ||||
| 
 | ||||
| progname_vty = progname_cli ++ "-vty" | ||||
|  | ||||
| @ -7,10 +7,6 @@ Released under GPL version 3 or later. | ||||
| 
 | ||||
| module Hledger.Web.Main where | ||||
| 
 | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import System.IO.UTF8 (putStr, putStrLn) | ||||
| #endif | ||||
| import Control.Concurrent (forkIO, threadDelay) | ||||
| import Network.Wai.Handler.SimpleServer (run) | ||||
| import System.Exit (exitFailure) | ||||
| @ -23,6 +19,8 @@ import Hledger.Cli.Options | ||||
| import Hledger.Cli.Utils (withJournalDo, openBrowserOn) | ||||
| import Hledger.Cli.Version (progversionstr, binaryfilename) | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import Hledger.Data.UTF8 (putStr, putStrLn) | ||||
| import Hledger.Web.App (App(..), withApp) | ||||
| import Hledger.Web.Files (createFilesIfMissing) | ||||
| import Hledger.Web.Settings (browserstartdelay, defhost, defport, datadir) | ||||
|  | ||||
| @ -15,13 +15,10 @@ import Hledger.Data | ||||
| import Hledger.Read.JournalReader (someamount) | ||||
| import Hledger.Cli.Options | ||||
| import Hledger.Cli.Register (registerReport, registerReportAsText) | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (putStr, putStrLn, getLine, appendFile) | ||||
| import System.IO.UTF8 | ||||
| import System.IO ( stderr ) | ||||
| #else | ||||
| import Prelude hiding (putStr, putStrLn, appendFile) | ||||
| import Hledger.Data.UTF8 (putStr, putStrLn, appendFile) | ||||
| 
 | ||||
| import System.IO ( stderr, hPutStrLn, hPutStr ) | ||||
| #endif | ||||
| import System.IO.Error | ||||
| import Text.ParserCombinators.Parsec | ||||
| import Hledger.Cli.Utils (readJournalWithOpts) | ||||
|  | ||||
| @ -111,10 +111,8 @@ import Hledger.Data.AccountName | ||||
| import Hledger.Data.Posting | ||||
| import Hledger.Data.Ledger | ||||
| import Hledger.Cli.Options | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding ( putStr ) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| import Prelude hiding (putStr) | ||||
| import Hledger.Data.UTF8 (putStr) | ||||
| 
 | ||||
| 
 | ||||
| -- | A balance report is a chart of accounts with balances, and their grand total. | ||||
|  | ||||
| @ -9,10 +9,8 @@ module Hledger.Cli.Histogram | ||||
| where | ||||
| import Hledger.Data | ||||
| import Hledger.Cli.Options | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding ( putStr ) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| import Prelude hiding (putStr) | ||||
| import Hledger.Data.UTF8 (putStr) | ||||
| 
 | ||||
| 
 | ||||
| barchar = '*' | ||||
|  | ||||
| @ -39,11 +39,8 @@ See "Hledger.Data.Ledger" for more examples. | ||||
| 
 | ||||
| module Hledger.Cli.Main where | ||||
| 
 | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding (putStr, putStrLn) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| 
 | ||||
| import Hledger.Data.UTF8 (putStr, putStrLn) | ||||
| import Hledger.Data | ||||
| import Hledger.Cli.Commands | ||||
| import Hledger.Cli.Options | ||||
|  | ||||
| @ -12,12 +12,10 @@ module Hledger.Cli.Print ( | ||||
|  ,journalReport | ||||
|  ,showTransactions | ||||
| ) where | ||||
| import Hledger.Data | ||||
| import Hledger.Cli.Options | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding ( putStr ) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr) | ||||
| import Hledger.Data.UTF8 (putStr) | ||||
| 
 | ||||
| 
 | ||||
| -- | A "journal report" is just a list of transactions. | ||||
|  | ||||
| @ -16,14 +16,13 @@ module Hledger.Cli.Register ( | ||||
| ) where | ||||
| 
 | ||||
| import Safe (headMay, lastMay) | ||||
| import Hledger.Data | ||||
| import Hledger.Cli.Options | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding ( putStr ) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| import Text.ParserCombinators.Parsec | ||||
| 
 | ||||
| import Hledger.Cli.Options | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr) | ||||
| import Hledger.Data.UTF8 (putStr) | ||||
| 
 | ||||
| 
 | ||||
| -- | A register report is a list of postings to an account or set of | ||||
| -- accounts, with a running total. Postings may be actual postings, or | ||||
|  | ||||
| @ -7,13 +7,12 @@ Print some statistics for the journal. | ||||
| 
 | ||||
| module Hledger.Cli.Stats | ||||
| where | ||||
| import Hledger.Data | ||||
| import Hledger.Cli.Options | ||||
| import qualified Data.Map as Map | ||||
| #if __GLASGOW_HASKELL__ <= 610 | ||||
| import Prelude hiding ( putStr ) | ||||
| import System.IO.UTF8 | ||||
| #endif | ||||
| 
 | ||||
| import Hledger.Cli.Options | ||||
| import Hledger.Data | ||||
| import Prelude hiding (putStr) | ||||
| import Hledger.Data.UTF8 (putStr) | ||||
| 
 | ||||
| 
 | ||||
| -- like Register.summarisePostings | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user