I very often want to place html or xml, as text, into html or xml. For example, blog posts often have html examples in them. I also need to insert xml into app config settings and code comment/documentation. This, of course, requires it be encoded so it does not get interpreted by the browser or, worse, blow up. Up until today I would manually replace all the < with < and the > with >. This was tedious and repetitive, indicating the need for automation!
I searched for an online utility. I know I've run across them, a text box where you can paste text and encode it. However, after ten minutes of searching, I realized I could write it in 5 minutes in c#.
Less then five minute later, I had a win32 form written in c# that accepted text in a text box and encoded it as either HtmlEncoded or UrlEncoded. It was unbelievably simple. Include a reference to System.Web in a .net windows forms application and use the System.Web.HttpUtility.HtmlEncode() or System.Web.HttpUtility.UrlEncode() method.
Since I was finished so quickly, I thought, "why not support UrlEndcoing as well?"
So I added the decode button and the calls to System.Web.HttpUtility.HtmlDecode() and System.Web.HttpUtility.UrlDecode().
This still left me around five minutes so I found a cool icon, wrote this short little excerpt, and shared it with y'all.
You just gotta LOVE .Net.
Included is the compile app that you are free to use and the source code that you are free to do with what you want.
http://vitaminzrecords.com/blog/content/binary/911a2a33-ca3c-40d1-9449-bbb55ebb89ae/Utility.HTMLEncoder.zip
Remember Me
Theme design by Jelle Druyts
Pick a theme: BlogXP calmBlue Candid Blue dasBlog Discreet Blog Blue Elegante essence Just Html Mono Movable Radio Blue Movable Radio Heat orangeCream Portal Project84 Slate Sound Waves Tricoleur
Powered by: newtelligence dasBlog 1.8.5223.2
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Rusty Zarse
E-mail