Lasso Soft Inc. > Home

[encode_decimalhtml]

Linkencode_decimalhtml
AuthorJason Huck
CategoryEncoding
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted21 Jun 2006
Updated21 Jun 2006
More by this author...

Description

Internet Explorer doesn't support certain HTML equivalents used by the built-in [encode_html] (such as ™ for ™). This custom tag instead uses decimal equivalents for the encoding (so, ™ becomes ™), which seems to be more compatible. It also strips out the non-printing character codes 0-8 which will also render incorrectly in IE otherwise.

Sample Usage

encode_decimalhtml($myText);

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(
	'decimalhtml',
	-namespace='encode_',
	-required='in', -copy,
	-priority='replace',
	-description='HTML-encodes strings using decimal values for better IE compatibility.'
);
	local(
		'in' = decode_html(#in),	// avoid double-encoding
		'out' = string,
		'reserved' = array(34,38,60,62)
	);
	
	iterate(#in, local('i'));
		if(
			#i->integer(1) > 127 
			|| #reserved >> #i->integer(1)
		);
			#out += '&#' + #i->integer(1) + ';';
		else(#i->integer(1) > 8);
			#out += #i;
		/if;
	/iterate;
	
	return(@#out);
/define_tag;

Related Tags

Comments

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