I'd like to url-encode some Text (e.g., replace each space with a %20, etc.). I found "HTTP" Network.HTTP.Base.urlEncode and could use that, but I'm wondering if there's something else that's normally used in the Yesod ecosystem.
相关问题
- Understanding do notation for simple Reader monad:
- Making Custom Instances of PersistBackend
- Haskell: What is the differrence between `Num [a]
- applying a list to an entered function to check fo
- Haskell split a list into two by a pivot value
相关文章
- Is it possible to write pattern-matched functions
- Haskell underscore vs. explicit variable
- Top-level expression evaluation at compile time
- Stuck in the State Monad
- foldr vs foldr1 usage in Haskell
- List of checkboxes with digestive-functors
- How does this list comprehension over the inits of
- Replacing => in place of -> in function type signa
Unfortunately, due to the complexity of URL escaping, the real answer is "it depends." There are slightly different rules for the percent encoding of path segments and query strings, for example.
I don't know exactly what you're trying to encode, but I'd recommend sticking to the http-types package. One place to start would be urlEncode, though there are many other functions in that packages (such as
encodePathSegments
mentioned by @jamshidh) which are worth looking at.As I understand it, URI encoding is complicated. However for my simple case, I was able to get by with the uri-encode package.
All I needed was:
As you can imagine, all it does it take a string, and give you back the URI-encoded version.