在Yesod生态系统中,urlencode一些文本的最佳方式是什么? [英] In the Yesod ecosystem, what is the best way to urlencode some Text?

查看:114
本文介绍了在Yesod生态系统中,urlencode一些文本的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对一些文本进行网址编码(例如,用%20替换每个空格等)。我发现了HTTPNetwork.HTTP.Base.urlEncode并可以使用它,但我想知道是否还有别的东西是Yesod生态系统中通常使用的。

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.

推荐答案

不幸的是,由于URL转义的复杂性,真正的答案是它取决于。例如,对于路径段和查询字符串的编码百分比略有不同。

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.

我不确切知道您要编码的内容,但我'd建议坚持使用http-types包。一个开始的地方是 urlEncode ,尽管该包中有很多其他功能(比如@jamshidh提到的 encodePathSegments ),值得一看。

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.

这篇关于在Yesod生态系统中,urlencode一些文本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆