简体   繁体   中英

Weird HtmlEncoding / Decoding Issue

I have a text that I am pulling in from an XML file. The text itself (as stored in the xml) has numerous html tags scattered throughout. I parse through this text and store it in a database and then later retrieve it and display it on screen. For the most part, it works fine. The HTML tags encode / decode properly and things render as I expect.

However, sometimes, the text itself also contains odd characters (think letters with accents, long dashes, etc). These are proving to be problematic and I can't figure out why. When I step through the code they have appropriately encoded values and if I use HtmlEncode or HtmlDecode they render the proper output character - but in my browser they look awful. For example, I have one piece of text that should say:

Dear Mrs. Budson —

It ends up rendering as

Dear Mrs. Budson —

When I look at what is stored in the database, it is stored as & # 8199 ; (without all the spaces). HtmlDecode() decodes this as — but my browser is displaying something completely different. Any ideas?

This may probably help. Don't have enough privileges to comment, hence answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM