esc - This function is used to apply a filter to a string.
esc(utf8:true or false,escape:"…",char:"…",nodouble:"true", filter:"br|multbr|lowercase|uppercase|json|isoapple|cleanhtml|char|dquotehtml |sql|sqlqm|html|filename|filenameinutf8 tex|latin1utf8|javascript|utf8latin1|uri|uriunescape|word|glyphsin|glyphsout, "…")}
The function is used to apply filters to a string.
Here is the list of parameters:
List of filters separated by commas.
Here is the list of filters:
Filename is a filter used to replace invalid character for filename with or the character specify by the parameter char. If nodouble is set to true, then they will be no adjacent.
Valid characters are a .. z, A .. Z, 0 .. 9
All others characters are replaced.
The following Latin1 characters are replaced with their equivalent character:
This is also valid for uppercase characters.
This filter is the same as FILENAME but works with utf8 characters.
This filter is used to escape invalid character in TeX. The following characters are preceded by a \:
ISO-8859-1 is the default character set in most browsers.
The first 128 characters of ISO-8859-1 is the original ASCII character-set (the numbers from 0-9, the uppercase and lowercase English alphabet, and some special characters).
The higher part of ISO-8859-1 (codes from 160-255) contains the characters used in Western European countries and some commonly used special characters.
Entities/glyphs are used to implement reserved characters or to express characters that cannot easily be entered with the keyboard.
Glyphsin is used to replace latin1 character over 0x7f to their entities counterpart.
As an example, the character é is replace by the entity é
non-breaking space ¡ ¡ ¡ inverted exclamation mark ¢ ¢ ¢ cent £ £ £ pound ¤ ¤ ¤ currency ¥ ¥ ¥ yen ¦ ¦ ¦ broken vertical bar § § § section ¨ ¨ ¨ spacing diaeresis © © © copyright ª ª ª feminine ordinal indicator « « « angle quotation mark (left) ¬ ¬ ¬ negation soft hyphen ® ® ® registered trademark ¯ ¯ ¯ spacing macron ° ° ° degree ± ± ± plus-or-minus ² ² ² superscript 2 ³ ³ ³ superscript 3 ´ ´ ´ spacing acute µ µ µ micro ¶ ¶ ¶ paragraph · · · middle dot ¸ ¸ ¸ spacing cedilla ¹ ¹ ¹ superscript 1 º º º masculine ordinal indicator » » » angle quotation mark (right) ¼ ¼ ¼ fraction 1/4 ½ ½ ½ fraction 1/2 ¾ ¾ ¾ fraction 3/4 ¿ ¿ ¿ inverted question mark × × × multiplication ÷ ÷ ÷ division À À À capital a, grave accent Á Á Á capital a, acute accent    capital a, circumflex accent à à à capital a, tilde Ä Ä Ä capital a, umlaut mark Å Å Å capital a, ring Æ Æ Æ capital ae Ç Ç Ç capital c, cedilla È È È capital e, grave accent É É É capital e, acute accent Ê Ê Ê capital e, circumflex accent Ë Ë Ë capital e, umlaut mark Ì Ì Ì capital i, grave accent Í Í Í capital i, acute accent Î Î Î capital i, circumflex accent Ï Ï Ï capital i, umlaut mark Ð Ð Ð capital eth, Icelandic Ñ Ñ Ñ capital n, tilde Ò Ò Ò capital o, grave accent Ó Ó Ó capital o, acute accent Ô Ô Ô capital o, circumflex accent Õ Õ Õ capital o, tilde Ö Ö Ö capital o, umlaut mark Ø Ø Ø capital o, slash Ù Ù Ù capital u, grave accent Ú Ú Ú capital u, acute accent Û Û Û capital u, circumflex accent Ü Ü Ü capital u, umlaut mark Ý Ý Ý capital y, acute accent Þ Þ Þ capital THORN, Icelandic ß ß ß small sharp s, German à à à small a, grave accent á á á small a, acute accent â â â small a, circumflex accent ã ã ã small a, tilde ä ä ä small a, umlaut mark å å å small a, ring æ æ æ small ae ç ç ç small c, cedilla è è è small e, grave accent é é é small e, acute accent ê ê ê small e, circumflex accent ë ë ë small e, umlaut mark ì ì ì small i, grave accent í í í small i, acute accent î î î small i, circumflex accent ï ï ï small i, umlaut mark ð ð ð small eth, Icelandic ñ ñ ñ small n, tilde ò ò ò small o, grave accent ó ó ó small o, acute accent ô ô ô small o, circumflex accent õ õ õ small o, tilde ö ö ö small o, umlaut mark ø ø ø small o, slash ù ù ù small u, grave accent ú ú ú small u, acute accent û û û small u, circumflex accent ü ü ü small u, umlaut mark ý ý ý small y, acute accent þ þ þ small thorn, Icelandic ÿ ÿ ÿ small y, umlaut mark
Note: In the followings examples, the _ between the { should be removed to make it work.
res={{esc(filter:"glyphsout,latin1utf8","ABCéa");}}. return res=ABCéa. res={{esc(filter:"glyphsout,latin1utf8","A&abcBCéa");}}. return res=A&abcBCéa. res={{esc(filter:"utf8latin1,glyphsin","ABCé");}}. return res=ABCé.
This filter is used to escape the following character:
The character are transformed in their hexadecimal form:
res={{esc(filter:"uri","str=<>#%\\"{}|\\^[]`;/?:@&=+$,");}}. return res=str%3d%3c%3e%23%25%22%7b%7d%7c%5c%5e%5b%5d%60%3b%2f%3f%3a%40%26%3d%2b.
This filter is used to put all characters in the range 0x00 to 0xff to lowercase depending on the current locale. This does not work with wide characters like utf8. Use lc for wide characters.
This filter is used to put all characters in the range 0x00 to 0xff to uppercase depending on the current locale. This does not work with wide characters like utf8. Use uc for wide characters.
This filter is used to quote a string for SQL. It add a \ before a ' or a Control-z or a null.
This filter is used to quote a string for SQL. It add a \ before a ' or a Control-z or a null. It also add a \ before ?.
Available at version 5.50 of sncode.
This filter transforms:
" in " & in & < in < > in > and ' in '
This filter transforms:
" in "
res={{a='"&<>abc"'; esc(filter:"dquotehtml",a);}}. return res="&<>abc". res={{a='"&<>abc"'; esc(filter:"dquotehtml,sql",a);}}. return res="&<>abc". res={{a='"&<\'>abc"'; esc(filter:"html,dquotehtml,sql",a);}}. return res="&<\'>abc".
This filter which can be used in a json string transform:
\b:"\\b" \n:"\\n" \r:"\\r" \t:"\\t" ":"\\\""
and transforms character less than space in their hexadeciman equivalent like \\u00xy
This filter preceeds the following characters by \:
This filter is used to replace newline or carriage return with the value of parameter escape including end of line with .
res={{esc(filter:"br","pi la");}}. return res=pi<br />la.
This filter is used to replace newline or carriage return with the value of parameter escape including end of line with .
The difference with BR is that multiple newline will be replace by multiple escape.
res={{esc(filter:"br","pi la");}}. return res=pi<br />la.
Transforms string from utf8 to latin1.
Removes % froms string.
res={{esc(filter:"uriunescape","ABC%2F");}}. return res=ABC/.
Transforms string from latin1 to utf8.
This filter is used to remove html tag from the string. A list of tag can be specified with parameter htmltag which by default is set to: p,/p,br,u,/u,i,/i,b,/b,strong,/strong
res={{esc(filter:"cleanhtml","a<p>a1</p><span class='text'><></span><aa");}}. return res=a<p>a1</p><><aa. res={{esc(filter:"cleanhtml","a<p class='bcd'>a1</p><span class='text'><></span><aa");}}. return )res=a<p class='bcd'>a1</p><><aa. res={{esc(filter:"cleanhtml",htmltag:"span,strong,/span", "a<p class='bcd'>a1</p><span class='text'><></span><aa");}}. return res=aa1<span class='text'><></span><aa.
Removes quote from string created by word
This filter is used to replace all instances of the parameter char by the value of parameter escape in the string.
res={{esc(filter:"char",escape:" ",char:"cc","pierrecclaplante");}}. return res=pierre laplante. res={{esc(filter:"char",escape:" ",char:"cc","pierreccclaplante");}}. return res=pierre claplante. res={{esc(filter:"char",escape:"''",char:"'","pierre'laplante");}}. return res=pierre''laplante. res={{esc(filter:"char",escape:"''",char:"'","pierre''laplante");}}. return res=pierre''''laplante. res={{esc(filter:"char",escape:"''",char:"'","pierrelaplante'");}}. return res=pierrelaplante''.
The value that we search in the list
The delimiter in the list which is set to comma by default
if isset(list:",bb,ccc,d",value:"d",delimiter:",") then "found"; else "not"; endif
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
1.0 2014-09-09 21:24:14 laplante@sednove.com
© 2024 extenso Inc. All rights reserved.