开发者

XML Character encoding to HTML

I am generating XML/HTML from my SQL Query to be placed in my frontend.

The problem is that the conversion from SQL > XML > HTML is not the same encoding.

Each html tag generated by SQL has a class so I want convert the encoding to display correctly in my front using jQuery.

Is there any good jQuery/Javascript function I can use to convert my generated html?

Example

é

Will convert to:

ã© 

And I want to convert it back to it's normal state.

SQL Example: This is how I get my XML/HTML from SQL in my SELECT Clause, column

htmlForFront = (SELECT ', ' + columnName + '' FROM tableName FOR XML path(''), elements) 

NOTE:

It would be easier for me to implement if it's client side (jQuery). But if I have no other choice C# would be fine开发者_开发问答.


ASSUMING the query as-is is drawing data, you can ensure the data is handled using "iso-8859-1" encoding by doing something like:

htmlForFront = (SELECT '<?xml version="1.0" encoding="ISO-8859-1" ?>' + (SELECT ', ' + columnName + '' FROM tableName FOR XML path(''), elements))

That way, it will get to the UI intact.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜