reworked functions to display Unicode correctly
This commit is contained in:
parent
bdbb3bed3e
commit
778f2c6e7a
|
@ -6,13 +6,16 @@ module Encoding.Base58
|
|||
import qualified Data.ByteString.Char8 as C
|
||||
import Data.ByteString.UTF8 as BSU -- from utf8-string
|
||||
import qualified Haskoin.Address.Base58 as B58
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.IO as T
|
||||
-- import qualified Data.Text.IO as T
|
||||
|
||||
dec58 :: String -> String
|
||||
dec58 input =
|
||||
maybe "Error decoding Base58.\n" C.unpack (B58.decodeBase58 (T.pack input))
|
||||
case B58.decodeBase58 (T.pack input) of
|
||||
Just decodedStr -> T.unpack (T.decodeUtf8 decodedStr)
|
||||
Nothing -> "Error decoding Base58.\n"
|
||||
|
||||
enc58 :: String -> String
|
||||
enc58 = T.unpack . B58.encodeBase58 . BSU.fromString
|
||||
|
|
|
@ -7,10 +7,13 @@ import qualified Codec.Binary.Base85 as B85
|
|||
import Data.ByteString.UTF8 as BSU -- from utf8-string
|
||||
import qualified Data.ByteString.Char8 as C
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
|
||||
dec85 :: String -> String
|
||||
dec85 input =
|
||||
case B85.decode (BSU.fromString input) of
|
||||
Right decodedStr -> C.unpack decodedStr
|
||||
Right decodedStr -> T.unpack (T.decodeUtf8 decodedStr)
|
||||
Left _ -> "Error decoding Base85.\n"
|
||||
|
||||
enc85 :: String -> String
|
||||
|
|
|
@ -7,10 +7,14 @@ import qualified Codec.Binary.QuotedPrintable as QP
|
|||
import Data.ByteString.UTF8 as BSU -- from utf8-string
|
||||
import qualified Data.ByteString.Char8 as C
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
-- import qualified Data.Text.IO as T
|
||||
|
||||
decqp :: String -> String
|
||||
decqp input =
|
||||
case QP.decode (BSU.fromString input) of
|
||||
Right decoded -> C.unpack decoded
|
||||
Right decoded -> T.unpack (T.decodeUtf8 decoded)
|
||||
Left _ -> "Error decoding QP.\n"
|
||||
|
||||
encqp :: String -> String
|
||||
|
|
|
@ -7,11 +7,15 @@ import qualified Codec.Binary.Uu as UU
|
|||
import Data.ByteString.UTF8 as BSU -- from utf8-string
|
||||
import qualified Data.ByteString.Char8 as C
|
||||
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.IO as T
|
||||
|
||||
decuu :: String -> String
|
||||
-- decuu = C.unpack . U.fromRight . UU.decode . BSU.fromString
|
||||
decuu input =
|
||||
case UU.decode (BSU.fromString input) of
|
||||
Right decoded -> C.unpack decoded
|
||||
Right decoded -> T.unpack (T.decodeUtf8 decoded)
|
||||
Left _ -> "Error decoding UU.\n"
|
||||
|
||||
encuu :: String -> String
|
||||
|
|
|
@ -6,11 +6,14 @@ module Encoding.Xx
|
|||
import qualified Codec.Binary.Xx as XX
|
||||
import Data.ByteString.UTF8 as BSU -- from utf8-string
|
||||
import qualified Data.ByteString.Char8 as C
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.IO as T
|
||||
|
||||
decxx :: String -> String
|
||||
decxx input =
|
||||
case XX.decode (BSU.fromString input) of
|
||||
Right decoded -> C.unpack decoded
|
||||
Right decoded -> T.unpack (T.decodeUtf8 decoded)
|
||||
Left _ -> "Error decoding XX.\n"
|
||||
|
||||
encxx :: String -> String
|
||||
|
|
|
@ -8,13 +8,16 @@ 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 -> C.unpack decoded
|
||||
Right decoded -> T.unpack (T.decodeUtf8 decoded)
|
||||
Left _ -> "Error decoding Y.\n"
|
||||
|
||||
|
||||
ency :: String -> String
|
||||
ency = C.unpack . Y.encode . BSU.fromString
|
||||
|
|
Loading…
Reference in New Issue