based/src/Encoding/Yenc.hs

24 lines
611 B
Haskell
Raw Normal View History

module Encoding.Yenc
( ency
, decy
) where
import Data.ByteString.UTF8 as BSU -- from utf8-string
import qualified Data.ByteString.Char8 as C
import qualified Codec.Binary.Yenc as Y
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Text.IO as T
decy :: String -> String
-- decy = C.unpack . U.fromRight . Y.decode . BSU.fromString
decy input =
case Y.decode (BSU.fromString input) of
Right decoded -> T.unpack (T.decodeUtf8 decoded)
Left _ -> "Error decoding Y.\n"
ency :: String -> String
ency = C.unpack . Y.encode . BSU.fromString