如何解决Clojure中等效于Python的html.unescape
在Python3中,我们有一个像这样的函数
Python 3.8.5 (v3.8.5:580fbb018f,Jul 20 2020,12:11:27)
>>> from html import unescape
>>> unescaped = unescape("here is ' apostrophe")
>>> print(unescaped)
here is ' apostrophe
>>>
我很难找到Clojure的对等物。基本库功能是否存在。
解决方法
图书馆apache.commons.text
可以完成此工作:
(ns tst.demo.core
(:use tupelo.core tupelo.test)
(:import
[org.apache.commons.text StringEscapeUtils]))
(dotest
(let [hng "hi & goodbye"
encoded (StringEscapeUtils/escapeHtml4 hng)]
(is= encoded "hi & goodbye")
(is= hng (StringEscapeUtils/unescapeHtml4 encoded))))
Apache站点有the full API docs。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。