Lasso Soft Inc. > Home

[lp_string_chr]

Linklp_string_chr
AuthorBil Corry
CategoryString
Version8.x
LicensePublic Domain
Posted17 Jan 2006
Updated03 Dec 2007
More by this author...

Description

Returns a character given an integer octet or an array of integer octets.

Requires [lp_math_decToOctet], [lp_math_hexToDec]

Sample Usage

For UTF-8:

[lp_string_chr: (lp_math_hextodec: 'C2A9')]
[lp_string_chr: 84] returns 'T'
[lp_string_chr: (array: 195, 164)] returns ä (a with umlaut)
[lp_string_chr: 50084] returns ä (a with umlaut)
[lp_string_chr: (array: 226,130,172)] returns euro symbol

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:'lp_string_chr',
	-description='Returns a character given an integer octet or an array of integer octets.',
	-priority='replace',
	-required='bytes', -copy,
	-optional='character_set',
	-optional='hex';

// http://www.unicode.org/charts/
// http://www.426.ch/ascii.html

	if: (local_defined:'hex');
		#bytes = (array: (lp_math_hexToDec:(string: #bytes)));
	/if;

	if: #bytes->type != 'array';	
		#bytes = (array: (integer: #bytes));
	/if;
	
	if: !(local_defined:'character_set');
		local:'character_set' = $__encoding__;
	/if;

	local:'return' = bytes;
	iterate: (lp_math_decToOctet: #bytes), local:'octet';
		#return->(import8bits: #octet);
	/iterate;
	
	return: #return->(exportstring: #character_set);

/define_tag;

]

Related Tags

Comments

No comments

Please log in to comment

LassoSoft Inc. > Home

 

 

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