Lasso Soft Inc. > Home


AuthorJohan Solve
LicensePublic Domain
Posted30 Oct 2008
Updated30 Oct 2008
More by this author...


When building RTF files by hand, the text content needs to be encoded properly according to RTF specifications. This tag encodes extended characters and linebreaks for use in RTF files, and converts the html tags <b>, <i> and <br> to the RTF correspondents.

This tag does NOT produce a complete RTF document, you need to take care of that yourself. It is only intended to help you encode the text properly.

Read more about the RTF format here:

Keep in mind that Lasso can also create RTF files with the PDF tags using PDF_Doc(-format='rtf'), but this tag is useful if you need to hand craft RTF files according to a specific format instead of creating full RTF documents from scratch.

Sample Usage

var('rtfdoc'=encode_rtf('This is a räksmörgås.

Now we are done!');

// add RTF prolog and end of document
$rtfdoc = '{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 Times New Roman;}}'
	+ $rtf_doc
	+ '}';

// serve the file

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag('encode_rtf', -required='input');
	#output -> replace('\r\n', '\n') & replace('\r', '\n');
	#output = encode_url(bytes(#output, 'windows-1252'));	
	#output -> replace('%0a', '\n') & replace('%20', ' ') & replace('%3c', '<') & replace('%3e', '>');
	#output -> replace(regexp(-find=']*>', -replace='\n', -ignorecase));
	#output -> replace('\n', '\\line ');
	#output -> replace(regexp(-find='%([0-9a-f]{2})', -replace='{\\\\\'\\1}', -ignorecase));
	#output -> replace(regexp(-find=']*>(.*?)', -replace='{\\\\b \\1}', -ignorecase));
	#output -> replace(regexp(-find=']*>(.*?)', -replace='{\\\\i \\1}', -ignorecase));


No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home



©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft