@@ -29,11 +29,9 @@ module Distribution.Utils.Generic (
29
29
-- * Unicode
30
30
31
31
-- ** Conversions
32
- fromUTF8 ,
33
32
fromUTF8BS ,
34
33
fromUTF8LBS ,
35
34
36
- toUTF8 ,
37
35
toUTF8BS ,
38
36
toUTF8LBS ,
39
37
@@ -43,8 +41,6 @@ module Distribution.Utils.Generic (
43
41
writeUTF8File ,
44
42
45
43
-- ** BOM
46
- startsWithBOM ,
47
- fileHasBOM ,
48
44
ignoreBOM ,
49
45
50
46
-- ** Misc
@@ -161,41 +157,18 @@ writeFileAtomic targetPath content = do
161
157
-- * Unicode stuff
162
158
-- ------------------------------------------------------------
163
159
164
- -- This is a modification of the UTF8 code from gtk2hs and the
165
- -- utf8-string package.
166
-
167
- {-# DEPRECATED fromUTF8 "Please use 'decodeStringUtf8', 'fromUTF8BS', or 'fromUTF8BS'" #-}
168
- fromUTF8 :: String -> String
169
- fromUTF8 = decodeStringUtf8 . map c2w
170
- where
171
- c2w c | c > ' \xFF ' = error " fromUTF8: invalid input data"
172
- | otherwise = fromIntegral (ord c)
173
-
174
160
fromUTF8BS :: SBS. ByteString -> String
175
161
fromUTF8BS = decodeStringUtf8 . SBS. unpack
176
162
177
163
fromUTF8LBS :: BS. ByteString -> String
178
164
fromUTF8LBS = decodeStringUtf8 . BS. unpack
179
165
180
- {-# DEPRECATED toUTF8 "Please use 'encodeStringUtf8', 'toUTF8BS', or 'toUTF8BS'" #-}
181
- toUTF8 :: String -> String
182
- toUTF8 = map (chr . fromIntegral ) . encodeStringUtf8
183
-
184
166
toUTF8BS :: String -> SBS. ByteString
185
167
toUTF8BS = SBS. pack . encodeStringUtf8
186
168
187
169
toUTF8LBS :: String -> BS. ByteString
188
170
toUTF8LBS = BS. pack . encodeStringUtf8
189
171
190
- -- | Whether BOM is at the beginning of the input
191
- startsWithBOM :: String -> Bool
192
- startsWithBOM (' \xFEFF ' : _) = True
193
- startsWithBOM _ = False
194
-
195
- -- | Check whether a file has Unicode byte order mark (BOM).
196
- fileHasBOM :: FilePath -> NoCallStackIO Bool
197
- fileHasBOM f = (startsWithBOM . fromUTF8LBS) <$> BS. readFile f
198
-
199
172
-- | Ignore a Unicode byte order mark (BOM) at the beginning of the input
200
173
--
201
174
ignoreBOM :: String -> String
0 commit comments