packages feed

punycode 0.5 → 0.5.1

raw patch · 2 files changed

+18/−2 lines, 2 filesdep +utf8-string

Dependencies added: utf8-string

Files

Data/Text/Punycode.hs view
@@ -1,4 +1,18 @@-module Data.Text.Punycode (encode, decode) where+module Data.Text.Punycode (encode, decode, internationalize) where +import qualified Data.ByteString as BS+import qualified Data.ByteString.UTF8 as UTF8BS+import Data.Char (isAscii)+ import Data.Text.Punycode.Encode (encode) import Data.Text.Punycode.Decode (decode)++-- | Convenience function for internationalized domain names. If there is+-- at least one non-ascii character, this function will encode the input+-- and prepend \"xn--\" to the output string. Otherwise, it will return the+-- string untouched. Note that this function does not run nameprep (e.g. it+-- operates on pre-prepped strings)+internationalize :: String -> BS.ByteString+internationalize x+  | all isAscii x = UTF8BS.fromString x+  | otherwise = UTF8BS.fromString "xn--" `BS.append` encode x
punycode.cabal view
@@ -1,5 +1,5 @@ name:            punycode-version:         0.5+version:         0.5.1 license:         BSD3 license-file:    LICENSE author:          Myles C. Maxfield <myles.maxfield@gmail.com>@@ -17,6 +17,7 @@                  , bytestring                  , cereal                  , mtl+                 , utf8-string     exposed-modules: Data.Text.Punycode     other-modules:   Data.Text.Punycode.Encode                    , Data.Text.Punycode.Decode@@ -32,6 +33,7 @@                  , mtl                  , HUnit                  , QuickCheck+                 , utf8-string  source-repository head   type:     git