It will be convenient to have a tool converting the source code to HTML encoded text, before I can post it on my blog article.
The following C# code is my tool to do the job:
public FormMain()
{
InitializeComponent();
}
private void buttonExit_Click(object sender, EventArgs e)
{
Close();
}
private void buttonRun_Click(object sender, EventArgs e)
{
string src = textBoxSrc.Text;
string html = System.Net.WebUtility.HtmlEncode(src);
textBoxHTML.Text = html;
textBoxHTML.SelectAll();
textBoxHTML.Copy();
}
private void textBoxSrc_MouseClick(object sender, MouseEventArgs e)
{
textBoxSrc.Text = "";
}
The UI:
Usage:
- Click on the textBoxSrc, the text in textBoxSrc will be cleaned. (line 26)
- Copy the source code to the textBoxSrc.
- Click the buttonRun.
- The converted text will be displayed on the textBoxHTML, in the same time, the text will also be copied to the clipboard for further use. (line 13 ~ 21)
You may use Visual Studio Community to create the project to adopt the code above and to create your tool.
Enjoy!
Comments