通过在 emacs 中调用 google dictionary api, http://www.google.com/dictionary/json? callback=cb&q=word&sl=en&tl=en&restrict=pr%%2Cde&client=te 我可以得到如下响应
"entries": [{
"type": "example",
"terms": [{
"type": "text",
"text": "his grandfather\x27s \x3cem\x3ewords\x3c/em\x3e had been meant kindly",
"language": "en"
}]
}]
如您所见,“文本”中有转义的 unicode。我想将它们转换为如下所示的功能。
(defun unescape-string (string)
"Return unescape unicode string"
...
)
(unescape-string "his grandfather\x27s \x3cem\x3ewords\x3c/em\x3e")
=> "his grandfathers's <em>words</em>"
(insert #x27)'
(insert #x27)'
(insert #x3c)<
(insert #x3e)>
这是我尝试过的
- 替换正则表达式字符串
- 自定义替换,如http://www.emacswiki.org/emacs/ElispCookbook#toc33
但是,我想我不知道如何用相应的 unicode 替换 '\x123' 到缓冲区或字符串中。
提前致谢