]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Utils.hs
staticDir
[Lucu.git] / Network / HTTP / Lucu / Utils.hs
index df19a76d251fdd42c66161e381ea6c45bece2be1..5dc1584683b5b23082cc3ae63cbd57ad293fe2e2 100644 (file)
@@ -4,6 +4,7 @@ module Network.HTTP.Lucu.Utils
     , trim         -- (a -> Bool) -> [a] -> [a]
     , noCaseEq     -- String -> String -> Bool
     , isWhiteSpace -- Char -> Bool
+    , quoteStr     -- String -> String
     )
     where
 
@@ -12,6 +13,7 @@ import Data.Char
 import Data.List
 import Foreign
 import Foreign.C
+import Network.URI
 
 
 splitBy :: (a -> Bool) -> [a] -> [[a]]
@@ -40,3 +42,11 @@ noCaseEq a b
 
 isWhiteSpace :: Char -> Bool
 isWhiteSpace = flip elem " \t\r\n"
+
+
+quoteStr :: String -> String
+quoteStr str = foldr (++) "" (["\""] ++ map quote str ++ ["\""])
+    where
+      quote :: Char -> String
+      quote '"' = "\\\""
+      quote c   = [c]
\ No newline at end of file