This patch fixes broken layout of some commands when there is Unicode text in the ledger file. I substituted System.IO functions with System.IO.UTF8. Now all strings are Unicode internally, and take's and length's work correctly. In particular, add, balance, hist, print and register commands seem to work correctly; ui is still broken for me, I didn't try web. I decode command line arguments from UTF8 forcefully, to permit searches for accounts and descriptions with Unicode (otherwise, it does not work). The patch adds an additional dependency: utf8-string. This patch does not include new test cases.
		
			
				
	
	
		
			28 lines
		
	
	
		
			776 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			776 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
{-| 
 | 
						|
 | 
						|
A ledger-compatible @print@ command.
 | 
						|
 | 
						|
-}
 | 
						|
 | 
						|
module PrintCommand
 | 
						|
where
 | 
						|
import Prelude hiding (putStr)
 | 
						|
import Ledger
 | 
						|
import Options
 | 
						|
import System.IO.UTF8
 | 
						|
 | 
						|
 | 
						|
-- | Print ledger transactions in standard format.
 | 
						|
print' :: [Opt] -> [String] -> Ledger -> IO ()
 | 
						|
print' opts args l = putStr $ showLedgerTransactions opts args l
 | 
						|
 | 
						|
showLedgerTransactions :: [Opt] -> [String] -> Ledger -> String
 | 
						|
showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredtxns
 | 
						|
    where 
 | 
						|
      filteredtxns = ledger_txns $ 
 | 
						|
                        filterRawLedgerPostingsByDepth depth $ 
 | 
						|
                        filterRawLedgerTransactionsByAccount apats $ 
 | 
						|
                        rawledger l
 | 
						|
      depth = depthFromOpts opts
 | 
						|
      (apats,_) = parseAccountDescriptionArgs opts args
 |