文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Copy Html To Clipboard

Copy Html To Clipboard

时间:2011-06-11  来源:誓言的爱

Copy Html To Clipboard 可解决中文乱码问题。

 private void CopyHtmlToClipBoard(string html)
{
Encoding enc
= Encoding.UTF8;

string begin = "Version:0.9\r\nStartHTML:{0:000000}\r\nEndHTML:{1:000000}\r\nStartFragment:{2:000000}\r\nEndFragment:{3:000000}\r\n";

string html_begin = "<html>\r\n<head>\r\n"
+ "<meta http-equiv=\"Content-Type\""
+ " content=\"text/html; charset=" + enc.WebName + "\">\r\n"
+ "<title>HTML clipboard</title>\r\n</head>\r\n<body>\r\n"
+ "<!--StartFragment-->";

string html_end = "<!--EndFragment-->\r\n</body>\r\n</html>\r\n";

string begin_sample = String.Format(begin, 0, 0, 0, 0);

int count_begin = enc.GetByteCount(begin_sample);
int count_html_begin = enc.GetByteCount(html_begin);
int count_html = enc.GetByteCount(html);
int count_html_end = enc.GetByteCount(html_end);

string html_total = String.Format(
begin
, count_begin
, count_begin
+ count_html_begin + count_html + count_html_end
, count_begin
+ count_html_begin
, count_begin
+ count_html_begin + count_html
)
+ html_begin + html + html_end;

DataObject obj
= new DataObject();
obj.SetData(DataFormats.Html,
new System.IO.MemoryStream(
enc.GetBytes(html_total)));
Clipboard.SetDataObject(obj,
true);
}

 转于:http://blog.tcx.be/2005/08/copying-html-fragment-to-clipboard.html

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载