web-encodings-0.0.1: Encapsulate multiple web encoding in a single package.

Portabilityportable
StabilityUnstable
MaintainerMichael Snoyman <michael@snoyman.com>

Web.Encodings

Contents

Description

Various web encodings.

Synopsis

Simple encodings.

URL (percentage encoding)

encodeUrl :: (LazyByteString x, LazyByteString y) => x -> ySource

Encode all but unreserved characters with percentage encoding.

Assumes use of UTF-8 character encoding.

decodeUrl :: (LazyByteString x, LazyByteString y) => x -> ySource

Decode percentage encoding. Assumes use of UTF-8 character encoding.

HTML (entity encoding)

encodeHtml :: String -> StringSource

Escape special HTML characters.

JSON

encodeJson :: LazyByteString x => String -> xSource

Perform JSON-encoding on a string. Does not wrap in quotation marks.

HTTP level encoding.

Query string- pairs of percentage encoding

encodeUrlPairs :: (LazyByteString x, LazyByteString y, LazyByteString z) => [(x, y)] -> zSource

Convert a list of key-values pairs into a query string. Does not include the question mark at the beginning.

decodeUrlPairs :: (LazyByteString x, LazyByteString y, LazyByteString z) => x -> [(y, z)]Source

Convert into key-value pairs. Strips the leading ? if necesary.

Post parameters

data FileInfo Source

Information on an uploaded file.

Instances

parseMultipartSource

Arguments

:: LazyByteString lbs 
=> lbs

boundary

-> ByteString

content

-> ([(String, String)], [(String, FileInfo)]) 

Parse a multipart form into parameters and files.

parsePostSource

Arguments

:: String

content type

-> String

content length

-> ByteString

body of the post

-> ([(String, String)], [(String, FileInfo)]) 

Parse a post request. This function determines the correct decoding function to use.

Cookies

decodeCookies :: String -> [(String, String)]Source

Decode the value of an HTTP_COOKIE header into key/value pairs.

Date/time encoding

formatW3 :: UTCTime -> StringSource

Format a UTCTime in W3 format; useful for setting cookies.