esc . string . sncode
ESC
NAME
esc - This function is used to apply a filter to a string.
SYNOPSIS
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, "…")}
DESCRIPTION
The function is used to apply filters to a string.
PARAMETERS
Here is the list of parameters:
FILTER
List of filters separated by commas ,.
FILENAME
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:
- éèêë are replaced by e
- àâäåãá are replaced by a
- ûüùú are replaced by u
- ïîìí are replaced by i
- ç are replaced by c
- ôòöóõ are replaced by o
- ñ is replaced by n
- ÿ is replaced by y
- æ is replaced by ae
This is also valid for uppercase characters.
FILENAMEINUTF8
This filter is the same as FILENAME but works with utf8 characters.
TEX
This filter is used to escape invalid character in TeX. The following characters are preceded by a \:
- \
- $
- ^
- &
- #
- {
- }
- %
- _
- The preceding rule is not applied in utf8.
GLYPHSIN
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é.
URI
This filter is used to escape the following character:
- All characters below 0x20
- All character over 0x7f
- The following list:
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.
LOWERCASE
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.
UPPERCASE
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.
SQL
This filter is used to quote a string for SQL. It add a \ before a ' or a Control-z or a null.
SQLQM
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.
HTML
This filter transforms:
" in " & in & < in < > in > and ' in '
DQUOTEHTML
This filter transforms:
" in "
res="&<>abc". return res="&<>abc". res="&<>abc". return res="&<>abc". res="&<'>abc". return res="&<\'>abc".
JSON
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
JAVASCRIPT
This filter preceeds the following characters by \:
- newline
- formfeed
- '
- "
- \b
- \t
- \f
BR
This filter is used to replace newline or carriage return with the value of parameter escape including end of line with .
res=pi la. return res=pi<br />la.
MULTBR
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=pi la. return res=pi<br />la.
UTF8LATIN1
Transforms string from utf8 to latin1.
URIUNESCAPE
Removes % froms string.
res=ABC/. return res=ABC/.
LATIN1UTF8
Transforms string from latin1 to utf8.
CLEANHTML
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=a<p>a1</p><span class='text'><></span><aa. return res=a<p>a1</p><><aa. res=a<p class='bcd'>a1</p><span class='text'><></span><aa. return )res=a<p class='bcd'>a1</p><><aa. res=a<p class='bcd'>a1</p><span class='text'><></span><aa. return res=aa1<span class='text'><></span><aa.
WORD
Removes quote from string created by word
CHAR
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''.
VALUE
The value that we search in the list
DELIMITER
The delimiter in the list which is set to comma by default
RETURN
-
- 0 if not found.
- position number if found starting at 1.
EXAMPLES
if isset(list:",bb,ccc,d",value:"d",delimiter:",") then "found"; else "not"; endif
AUTHOR
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>