Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [FEATURE + patch]WriteClipboardHTML and HtmlToText functions
[FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51306] |
Mon, 04 March 2019 15:55 |
omari
Messages: 275 Registered: March 2010
|
Experienced Member |
|
|
void WriteClipboardHTML(const String& html) :
write the html into clipboard in HTML Format, useful to export formatted text
it write too the extracted text from html, in Unicode Text Format, can be used if the client does not support HTML Format
WString HtmlToText(String s, bool showLinks = false):
extract text from html, showLinks specify if it include link targets or not.
the zip containe package with the functions and tests.
regards
omari.
|
|
|
Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51380 is a reply to message #51306] |
Sun, 17 March 2019 10:44 |
|
mirek
Messages: 14162 Registered: November 2005
|
Ultimate Member |
|
|
Both functions are handy, but I am undecided about HtmlToText.
Also, I was feeling a little bit uneasy about possiblity of <HTML> string (or that marker comment) being inside html, so I have slightly changed the function to:
void WriteClipboardHTML(const String& html)
{
String data;
data =
"Version:0.9\n"
"StartHTML:#000001#\n"
"EndHTML:#000002#\n"
"StartFragment:#000003#\n"
"EndFragment:#000004#\n"
"StartSelection:#000003#\n"
"EndSelection:#000004#\n"
"<HTML>\n"
"<!--StartFragment -->"
"<!--EndFragment -->\n"
"</HTML>\n"
;
data.Replace("#000001#", Sprintf("%08u", data.Find("<HTML>") + 6));
int start = data.Find("<!--StartFragment -->") + 21;
data.Replace("#000003#", Sprintf("%08u", start));
data.Replace("#000004#", Sprintf("%08u", data.Find("<!--EndFragment -->") + html.GetCount()));
data.Replace("#000002#", Sprintf("%08u", data.Find("</HTML>") + html.GetCount()));
data.Insert(start, html);
WriteClipboard("HTML Format", data);
}
In this form, I am adding this to CtrlCore.
Mire
[Updated on: Sun, 17 March 2019 10:45] Report message to a moderator
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Dec 13 22:18:04 CET 2024
Total time taken to generate the page: 0.02511 seconds
|