Lasso Soft Inc. > Home

[lp_string_ucs]

Linklp_string_ucs
AuthorBil Corry
CategoryString
Version8.x
LicensePublic Domain
Posted06 Dec 2005
Updated07 Dec 2005
More by this author...

Description

Returns the UCS decimal value of a given character.  Optionally may return it as a hex or binary value.  Empty strings and nulls return the value zero.

Requires [lp_math_dectohex], [lp_math_dectobin]

Sample Usage

lp_string_ucs:'a';'
'; // returns 97 lp_string_ucs:'a',-hex;'
'; // returns 61 lp_string_ucs:'a',-bin;'
'; // returns 1100001 lp_string_ucs:'ä';'
'; // returns 228 lp_string_ucs:'ä',-hex;'
'; // returns E4 lp_string_ucs:'ä',-bin;'
'; // returns 11100100

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_ucs',
	-description='Returns the UCS decimal value of a given character.',
	-priority='replace',
	-required='char', -copy;

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

	#char = string: #char;
	
	if: #char->size == 0;
		return: 0;
	/if;
	
	if: params->(find: '-hex')->size;
		return: (lp_math_dectohex: #char->(get:1)->integer);
	else: params->(find: '-bin')->size;
		return: (lp_math_dectobin: #char->(get:1)->integer);
	/if;
	
	// default = decimal
	return: #char->(get:1)->integer;

/define_tag;

]

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