Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
omari is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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

Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51381 is a reply to message #51380] Sun, 17 March 2019 10:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14162
Registered: November 2005
Ultimate Member
P.S.: On what platform(s) is this tested? Linux / Win32 / MacOS ?

Mirek

[Updated on: Sun, 17 March 2019 10:47]

Report message to a moderator

Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51384 is a reply to message #51381] Sun, 17 March 2019 13:52 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 275
Registered: March 2010
Experienced Member
This is the Win32 version.

trying to test it on linux and with a bit of investigation, i found that
the Linux version is as easy as

void WriteClipboardHTML(const String& html)
{
	WriteClipboard("text/html", html);
}

(tested on Ubuntu/ Gnome)

I dont have a MacOS machine, then i have not tested it.


regards
omari.

[Updated on: Sun, 17 March 2019 14:29]

Report message to a moderator

Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51386 is a reply to message #51384] Mon, 18 March 2019 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14162
Registered: November 2005
Ultimate Member
omari wrote on Sun, 17 March 2019 13:52
This is the Win32 version.

trying to test it on linux and with a bit of investigation, i found that
the Linux version is as easy as

void WriteClipboardHTML(const String& html)
{
	WriteClipboard("text/html", html);
}

(tested on Ubuntu/ Gnome)

I dont have a MacOS machine, then i have not tested it.


Well, maybe that one would work in win32 too? Smile

Mirek
Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #51389 is a reply to message #51386] Mon, 18 March 2019 12:31 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 275
Registered: March 2010
Experienced Member
no, it does not work on win32. Smile


regards
omari.
Re: [FEATURE + patch]WriteClipboardHTML and HtmlToText functions [message #57646 is a reply to message #51306] Fri, 05 November 2021 17:39 Go to previous message
Lance is currently offline  Lance
Messages: 633
Registered: March 2007
Contributor
It doens't work on Ubuntu 20.04. With most recent TheIDE (version 15947).

[Updated on: Fri, 05 November 2021 17:39]

Report message to a moderator

Previous Topic: curl
Next Topic: How to detect available OpenGL memory?
Goto Forum:
  


Current Time: Fri Dec 13 22:18:04 CET 2024

Total time taken to generate the page: 0.02511 seconds