How to decode html encoded text in sql server? (or ms access!)

匿名 (未验证) 提交于 2019-12-03 01:39:01

问题:

I have a column with text in the following format...

sweet shop

is there a way to convert this directly to it's corresponding text in sql server? (it is actually a linked ms access database so I could also use access too!)

(I think this format is also called Numeric character reference and contains the code points of unicode characters)

回答1:

Alex K is 99.99% correct, however the conversion would fail if you had Named Codes like   or £

So, here we perform a brute force replace, and then parse the string via XML

Example

Returns



回答2:

Here is a much easier way to decode HTML-encoded strings:

It requires SQLHTTP which is a free database/assembly that we created which you can find on our website at: http://sqlhttp.net/documentation/encoding/htmldecode/

SELECT SQLHTTP.net.HtmlDecode('sweet shop')

and the result is as expected:

------------- sweet shop  (1 row affected)


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!