Jump to content
Server Maintenance This Week. ×

HTML Entities


This topic is 3860 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Name & Parameters: HTMLEntities( text ; pointer ; store )

Description: Converts punctuation and symbols in 'text' to HTML entities, starting at position 'pointer'

Set the 'store' parameter to "" - If you give it a value it will prefix your output with that value.

 

Caution: This function will render inputted HTML non-functional. Since it will destroy the tags by replacing < and > with HTML entities.

 


Recursive: Yes

Sample Input:



Hi, I'm some text with some symbols or punctuation to convert to HTML entities! ?&/

Results:


Hi&#44; I&#39;m some text with some symbols or punctuation to convert to HTML entities&#33; &#63;&#38;&#47;

Formula:



/*
HTMLEntities
Converts punctuation/symbol characters in text into HTML entities, starting at position pointer
Free to use - attribution to my fmforums nickname would be nice
uemtux Oct 10, 2013
*/
Let(
[
step = Middle(text ; pointer ; 1);
step = Case(
//step = " " ; "&#32;" ; // Uncomment to replace spaces with entity codes
step = "!" ; "&#33;" ;
step = """ ; "&#34;" ; 
step = "#" ; "&#35;" ;
step = "$" ; "&#36;" ;  
step = "%" ; "&#37;" ; 
step = "&" ; "&#38;" ; 
step = "'" ; "&#39;" ;
step = "(" ; "&#40;" ;  
step = ")" ; "&#41;" ;  
step = "*" ; "&#42;" ; 
step = "+" ; "&#43;" ;   
step = "," ; "&#44;" ;
step = "-" ; "&#45;" ;
step = "." ; "&#46;" ;
step = "/" ; "&#47;" ;
step = ":" ; "&#58;" ;
step = ";" ; "&#59;" ;
step = "<" ; "&#60;" ;
step = "=" ; "&#61;" ;
step = ">" ; "&#62;" ;
step = "?" ; "&#63;" ;
step = "@" ; "&#64;" ;
step = "[" ; "&#91;" ;
step = "" ; "&#92;" ;
step = "]" ; "&#93;" ;
step = "^" ; "&#94;" ;
step = "_" ; "&#95;" ;
step = "`" ;  "&#96;" ;
step = "{" ;  "&#123;" ;
step = "|" ;  "&#124;" ;
step = "}" ;  "&#125;" ;
step = "~" ;  "&#126;" ; step);
store = store & step;
pointer = pointer + 1
];
Case(pointer > Length(text) ; store ; HTMLEntities(text ; pointer ; store))
)

Required Functions:

None.

 

 

Credits:

Got my info here: http://www.w3schools.com/tags/ref_ascii.asp

 



Disclaimer: FM Forums does not endorse or warrantee these functions are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.
Link to comment
Share on other sites

This topic is 3860 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.