2024-05-19 13:23:39 +02:00
|
|
|
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
|
|
|
|
|
2024-05-20 23:28:14 +02:00
|
|
|
import qualified Data.Text as T
|
|
|
|
import qualified Data.Text.Encoding as T
|
|
|
|
import qualified Data.Text.IO as T
|
|
|
|
|
2024-05-19 13:23:39 +02:00
|
|
|
decy :: String -> String
|
|
|
|
-- decy = C.unpack . U.fromRight . Y.decode . BSU.fromString
|
|
|
|
decy input =
|
|
|
|
case Y.decode (BSU.fromString input) of
|
2024-05-20 23:28:14 +02:00
|
|
|
Right decoded -> T.unpack (T.decodeUtf8 decoded)
|
2024-05-19 13:23:39 +02:00
|
|
|
Left _ -> "Error decoding Y.\n"
|
|
|
|
|
|
|
|
ency :: String -> String
|
|
|
|
ency = C.unpack . Y.encode . BSU.fromString
|