[encode_decimalhtml]

Description

Link: [encode_decimalhtml]
Author: Jason Huck
Category: Encoding
Version: 8.x
License:
Posted: Jun. 21, 2006
Updated: Jan. 01, 0001
More by this author...
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.

Parameters

none


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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

none

Email:


Password:



Newest

Most Popular