~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/Utils/IO/UTF8.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane, d5cf60f
  • Date: 2015-05-20 13:08:33 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20150520130833-cdcmhagwsouna237
Tags: 2.4.2.2-2
[d5cf60f] Depend on ${shlibs:Depends}, to get libc (& maybe other) deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import qualified System.IO as IO
10
10
import Control.Applicative
11
11
 
12
 
import Agda.Utils.Unicode
 
12
-- | Converts many character sequences which may be interpreted as
 
13
-- line or paragraph separators into '\n'.
 
14
 
 
15
convertLineEndings :: String -> String
 
16
-- ASCII:
 
17
convertLineEndings ('\x000D' : '\x000A' : s) = '\n' : convertLineEndings s  -- CR LF
 
18
convertLineEndings ('\x000A'            : s) = '\n' : convertLineEndings s  -- LF  (Line feed)
 
19
convertLineEndings ('\x000D'            : s) = '\n' : convertLineEndings s  -- CR  (Carriage return)
 
20
convertLineEndings ('\x000C'            : s) = '\n' : convertLineEndings s  -- FF  (Form feed)
 
21
-- Unicode:
 
22
convertLineEndings ('\x0085'            : s) = '\n' : convertLineEndings s  -- NEXT LINE
 
23
convertLineEndings ('\x2028'            : s) = '\n' : convertLineEndings s  -- LINE SEPARATOR
 
24
convertLineEndings ('\x2029'            : s) = '\n' : convertLineEndings s  -- PARAGRAPH SEPARATOR
 
25
-- Not a line ending:
 
26
convertLineEndings (c                   : s) = c    : convertLineEndings s
 
27
convertLineEndings ""                        = ""
13
28
 
14
29
-- | Reads a UTF8-encoded text file and converts all Unicode line
15
30
-- endings into '\n'.