adding sq_htmlentities function
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 25 Apr 2004 10:04:57 +0000 (10:04 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 25 Apr 2004 10:04:57 +0000 (10:04 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7233 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/htmlentities/index.php [new file with mode: 0644]
functions/htmlentities/iso-8859-1.php [new file with mode: 0644]
functions/htmlentities/readme.php [new file with mode: 0644]
functions/htmlentities/utf-8.php [new file with mode: 0644]
functions/strings.php

diff --git a/functions/htmlentities/index.php b/functions/htmlentities/index.php
new file mode 100644 (file)
index 0000000..5963dfd
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Redirects to the login page.
+ *
+ * @copyright (c) 1999-2004 The SquirrelMail development team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage strings
+ */
+header("Location:../../src/login.php\n\n");
+exit();
+?>
diff --git a/functions/htmlentities/iso-8859-1.php b/functions/htmlentities/iso-8859-1.php
new file mode 100644 (file)
index 0000000..981eccb
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+/**
+ * iso-8859-1 html entities table
+ *
+ * @copyright (c) 2004 The SquirrelMail development team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage strings
+ */
+$sq_html_ent_table = array_merge($sq_html_ent_table,
+       array("\xA0" => '&nbsp;',
+             "\xA1" => '&iexcl;',
+             "\xA2" => '&cent;',
+             "\xA3" => '&pound;',
+             "\xA4" => '&curren;',
+             "\xA5" => '&yen;',
+             "\xA6" => '&brvbar;',
+             "\xA7" => '&sect;',
+             "\xA8" => '&uml;',
+             "\xA9" => '&copy;',
+             "\xAA" => '&ordf;',
+             "\xAB" => '&laquo;',
+             "\xAC" => '&not;',
+             "\xAD" => '&shy;',
+             "\xAE" => '&reg;',
+             "\xAF" => '&macr;',
+             "\xB0" => '&deg;',
+             "\xB1" => '&plusmn;',
+             "\xB2" => '&sup2;',
+             "\xB3" => '&sup3;',
+             "\xB4" => '&acute;',
+             "\xB5" => '&micro;',
+             "\xB6" => '&para;',
+             "\xB7" => '&middot;',
+             "\xB8" => '&cedil;',
+             "\xB9" => '&sup1;',
+             "\xBA" => '&ordm;',
+             "\xBB" => '&raquo;',
+             "\xBC" => '&frac14;',
+             "\xBD" => '&frac12;',
+             "\xBE" => '&frac34;',
+             "\xBF" => '&iquest;',
+             "\xC0" => '&Agrave;',
+             "\xC1" => '&Aacute;',
+             "\xC2" => '&Acirc;',
+             "\xC3" => '&Atilde;',
+             "\xC4" => '&Auml;',
+             "\xC5" => '&Aring;',
+             "\xC6" => '&AElig;',
+             "\xC7" => '&Ccedil;',
+             "\xC8" => '&Egrave;',
+             "\xC9" => '&Eacute;',
+             "\xCA" => '&Ecirc;',
+             "\xCB" => '&Euml;',
+             "\xCC" => '&Igrave;',
+             "\xCD" => '&Iacute;',
+             "\xCE" => '&Icirc;',
+             "\xCF" => '&Iuml;',
+             "\xD0" => '&ETH;',
+             "\xD1" => '&Ntilde;',
+             "\xD2" => '&Ograve;',
+             "\xD3" => '&Oacute;',
+             "\xD4" => '&Ocirc;',
+             "\xD5" => '&Otilde;',
+             "\xD6" => '&Ouml;',
+             "\xD7" => '&times;',
+             "\xD8" => '&Oslash;',
+             "\xD9" => '&Ugrave;',
+             "\xDA" => '&Uacute;',
+             "\xDB" => '&Ucirc;',
+             "\xDC" => '&Uuml;',
+             "\xDD" => '&Yacute;',
+             "\xDE" => '&THORN;',
+             "\xDF" => '&szlig;',
+             "\xE0" => '&agrave;',
+             "\xE1" => '&aacute;',
+             "\xE2" => '&acirc;',
+             "\xE3" => '&atilde;',
+             "\xE4" => '&auml;',
+             "\xE5" => '&aring;',
+             "\xE6" => '&aelig;',
+             "\xE7" => '&ccedil;',
+             "\xE8" => '&egrave;',
+             "\xE9" => '&eacute;',
+             "\xEA" => '&ecirc;',
+             "\xEB" => '&euml;',
+             "\xEC" => '&igrave;',
+             "\xED" => '&iacute;',
+             "\xEE" => '&icirc;',
+             "\xEF" => '&iuml;',
+             "\xF0" => '&eth;',
+             "\xF1" => '&ntilde;',
+             "\xF2" => '&ograve;',
+             "\xF3" => '&oacute;',
+             "\xF4" => '&ocirc;',
+             "\xF5" => '&otilde;',
+             "\xF6" => '&ouml;',
+             "\xF7" => '&divide;',
+             "\xF8" => '&oslash;',
+             "\xF9" => '&ugrave;',
+             "\xFA" => '&uacute;',
+             "\xFB" => '&ucirc;',
+             "\xFC" => '&uuml;',
+             "\xFD" => '&yacute;',
+             "\xFE" => '&thorn;',
+             "\xFF" => '&yuml;')
+               );
+?>
\ No newline at end of file
diff --git a/functions/htmlentities/readme.php b/functions/htmlentities/readme.php
new file mode 100644 (file)
index 0000000..a7abba8
--- /dev/null
@@ -0,0 +1,317 @@
+<?php
+/**
+ * SquirrelMail html translation table documentation
+ *
+ * SquirrelMail provides own implementation of htmlentities() and
+ * get_html_translation_table() functions. Functions are called
+ * sq_get_html_translation_table() and sq_htmlentities(). They are 
+ * included in functions/strings.php
+ *
+ * sq_htmlentities uses same syntax as functions available in php 4.1.0
+ * sq_get_html_translation_table adds third option that sets charset.
+ *
+ * string sq_htmlentities ( string string [, int quote_style [, string charset]])
+ * array sq_get_html_translation_table ( int table [, int quote_style [, string charset]])
+ *
+ * If sq_get_html_translation_table function is called with HTML_SPECIALCHARS option,
+ * it returns us-ascii translation table. If it is called with HTML_ENTITIES option,
+ * it returns translation table defined by charset. Function defaults to us-ascii charset
+ * and not to iso-8859-1.
+ *
+ * Why own functions are used instead of htmlspecialchars() and 
+ * htmlentities() provided by php.
+ *
+ * a) removes dependency on options available only in php v.4.1+
+ * b) default behavior of htmlentities() is disastrous in non iso-8859-1 environment.
+ * c) provides better control of transformations.
+ *
+ * --- Full list of entities (w3.org html4.01 recommendations)
+ * 1. regural symbols
+ * U+0022 - &quot;
+ *          (replaced only when $style is not ENT_NOQUOTES or 0)
+ * U+0026 - &amp;
+ * U+0027 - &#39;
+ *          (replaced only when $style is ENT_QUOTES or 3)
+ * U+003C - &lt;
+ * U+003E - &gt;
+ *
+ * 2. latin1 symbols (HTMLlat1.ent)
+ * U+00A0 - &nbsp;    -- no-break space = non-breaking space
+ * U+00A1 - &iexcl;   -- inverted exclamation mark
+ * U+00A2 - &cent;    -- cent sign
+ * U+00A3 - &pound;   -- pound sign
+ * U+00A4 - &curren;  -- currency sign
+ * U+00A5 - &yen;     -- yen sign
+ * U+00A6 - &brvbar;  -- broken bar
+ * U+00A7 - &sect;    -- section sign
+ * U+00A8 - &uml;     -- diaeresis
+ * U+00A9 - &copy;    -- copyright sign
+ * U+00AA - &ordf;    -- feminine ordinal indicator
+ * U+00AB - &laquo;   -- left-pointing double angle quotation mark = left pointing guillemet
+ * U+00AC - &not;     -- not sign
+ * U+00AD - &shy;     -- soft hyphen = discretionary hyphen
+ * U+00AE - &reg;     -- registered sign = registered trade mark sign
+ * U+00AF - &macr;    -- macron = spacing macron = overline = APL overbar
+ * U+00B0 - &deg;     -- degree sign
+ * U+00B1 - &plusmn;  -- plus-minus sign = plus-or-minus sign
+ * U+00B2 - &sup2;    -- superscript two = superscript digit two = squared
+ * U+00B3 - &sup3;    -- superscript three = superscript digit three = cubed
+ * U+00B4 - &acute;   -- acute accent = spacing acute
+ * U+00B5 - &micro;   -- micro sign
+ * U+00B6 - &para;    -- pilcrow sign = paragraph sign
+ * U+00B7 - &middot;  -- middle dot = Georgian comma = Greek middle dot
+ * U+00B8 - &cedil;   -- cedilla = spacing cedilla
+ * U+00B9 - &sup1;    -- superscript one = superscript digit one
+ * U+00BA - &ordm;    -- masculine ordinal indicator
+ * U+00BB - &raquo;   -- right-pointing double angle quotation mark = right pointing guillemet
+ * U+00BC - &frac14;  -- vulgar fraction one quarter = fraction one quarter
+ * U+00BD - &frac12;  -- vulgar fraction one half = fraction one half
+ * U+00BE - &frac34;  -- vulgar fraction three quarters = fraction three quarters
+ * U+00BF - &iquest;  -- inverted question mark = turned question mark
+ * U+0180 - &Agrave;  -- latin capital letter A with grave = latin capital letter A grave,
+ * U+0181 - &Aacute;  -- latin capital letter A with acute
+ * U+0182 - &Acirc;   -- latin capital letter A with circumflex
+ * U+0183 - &Atilde;  -- latin capital letter A with tilde
+ * U+0184 - &Auml;    -- latin capital letter A with diaeresis
+ * U+0185 - &Aring;   -- latin capital letter A with ring above = latin capital letter A ring
+ * U+0186 - &AElig;   -- latin capital letter AE = latin capital ligature AE
+ * U+0187 - &Ccedil;  -- latin capital letter C with cedilla
+ * U+0188 - &Egrave;  -- latin capital letter E with grave
+ * U+0189 - &Eacute;  -- latin capital letter E with acute
+ * U+018A - &Ecirc;   -- latin capital letter E with circumflex
+ * U+018B - &Euml;    -- latin capital letter E with diaeresis
+ * U+018C - &Igrave;  -- latin capital letter I with grave
+ * U+018D - &Iacute;  -- latin capital letter I with acute
+ * U+018E - &Icirc;   -- latin capital letter I with circumflex
+ * U+018F - &Iuml;    -- latin capital letter I with diaeresis
+ * U+0190 - &ETH;     -- latin capital letter ETH
+ * U+0191 - &Ntilde;  -- latin capital letter N with tilde
+ * U+0192 - &Ograve;  -- latin capital letter O with grave
+ * U+0193 - &Oacute;  -- latin capital letter O with acute
+ * U+0194 - &Ocirc;   -- latin capital letter O with circumflex
+ * U+0195 - &Otilde;  -- latin capital letter O with tilde
+ * U+0196 - &Ouml;    -- latin capital letter O with diaeresis
+ * U+0197 - &times;   -- multiplication sign
+ * U+0198 - &Oslash;  -- latin capital letter O with stroke = latin capital letter O slash
+ * U+0199 - &Ugrave;  -- latin capital letter U with grave
+ * U+019A - &Uacute;  -- latin capital letter U with acute
+ * U+019B - &Ucirc;   -- latin capital letter U with circumflex
+ * U+019C - &Uuml;    -- latin capital letter U with diaeresis
+ * U+019D - &Yacute;  -- latin capital letter Y with acute
+ * U+019E - &THORN;   -- latin capital letter THORN
+ * U+019F - &szlig;   -- latin small letter sharp s = ess-zed
+ * U+01A0 - &agrave;  -- latin small letter a with grave = latin small letter a grave
+ * U+01A1 - &aacute;  -- latin small letter a with acute
+ * U+01A2 - &acirc;   -- latin small letter a with circumflex
+ * U+01A3 - &atilde;  -- latin small letter a with tilde
+ * U+01A4 - &auml;    -- latin small letter a with diaeresis
+ * U+01A5 - &aring;   -- latin small letter a with ring above = latin small letter a ring
+ * U+01A6 - &aelig;   -- latin small letter ae = latin small ligature ae
+ * U+01A7 - &ccedil;  -- latin small letter c with cedilla
+ * U+01A8 - &egrave;  -- latin small letter e with grave
+ * U+01A9 - &eacute;  -- latin small letter e with acute
+ * U+01AA - &ecirc;   -- latin small letter e with circumflex
+ * U+01AB - &euml;    -- latin small letter e with diaeresis
+ * U+01AC - &igrave;  -- latin small letter i with grave
+ * U+01AD - &iacute;  -- latin small letter i with acute
+ * U+01AE - &icirc;   -- latin small letter i with circumflex
+ * U+01AF - &iuml;    -- latin small letter i with diaeresis
+ * U+01B0 - &eth;     -- latin small letter eth
+ * U+01B1 - &ntilde;  -- latin small letter n with tilde
+ * U+01B2 - &ograve;  -- latin small letter o with grave
+ * U+01B3 - &oacute;  -- latin small letter o with acute
+ * U+01B4 - &ocirc;   -- latin small letter o with circumflex
+ * U+01B5 - &otilde;  -- latin small letter o with tilde
+ * U+01B6 - &ouml;    -- latin small letter o with diaeresis
+ * U+01B7 - &divide;  -- division sign
+ * U+01B8 - &oslash;  -- latin small letter o with stroke = latin small letter o slash,
+ * U+01B9 - &ugrave;  -- latin small letter u with grave
+ * U+01BA - &uacute;  -- latin small letter u with acute
+ * U+01BB - &ucirc;   -- latin small letter u with circumflex
+ * U+01BC - &uuml;    -- latin small letter u with diaeresis
+ * U+01BD - &yacute;  -- latin small letter y with acute
+ * U+01BE - &thorn;   -- latin small letter thorn,
+ * U+01BF - &yuml;    -- latin small letter y with diaeresis
+ *
+ * 3. Special symbols (HTMLspecial.ent)
+ * Latin Extended-A
+ * U+0152 - &OElig;  --
+ * U+0153 - &oelig;  -- latin small ligature oe
+ * U+0160 - &Scaron; -- latin capital letter S with caron
+ * U+0161 - &scaron; -- latin small letter s with caron
+ * U+0178 - &Yuml;   -- latin capital letter Y with diaeresis
+ * Spacing Modifier Letters
+ * U+02C6 - &circ;   -- modifier letter circumflex accent
+ * U+02DC - &tilde;  -- small tilde
+ * General Punctuation
+ * U+2002 - &ensp;   -- en space
+ * U+2003 - &emsp;   -- em space
+ * U+2009 - &thinsp; -- thin space
+ * U+200C - &zwnj;   -- zero width non-joiner
+ * U+200D - &zwj;    -- zero width joiner
+ * U+200E - &lrm;    -- left-to-right mark
+ * U+200F - &rlm;    -- right-to-left mark
+ * U+2013 - &ndash;  -- en dash
+ * U+2014 - &mdash;  -- em dash
+ * U+2018 - &lsquo;  -- left single quotation mark
+ * U+2019 - &rsquo;  -- right single quotation mark
+ * U+201A - &sbquo;  -- single low-9 quotation mark
+ * U+201C - &ldquo;  -- left double quotation mark
+ * U+201D - &rdquo;  -- right double quotation mark
+ * U+201E - &bdquo;  -- double low-9 quotation mark
+ * U+2020 - &dagger; -- dagger
+ * U+2021 - &Dagger; -- double dagger
+ * U+2030 - &permil; -- per mille sign
+ * U+2039 - &lsaquo; -- single left-pointing angle quotation mark
+ * U+203A - &rsaquo; -- single right-pointing angle quotation mark
+ * U+20AC - &euro;   -- euro sign
+ *
+ * 4. Other symbols (HTMLsymbol.ent)
+ * Latin Extended-B
+ * U+0192 - &fnof;   -- latin small f with hook = function = florin
+ * Greek
+ * U+0391 - &Alpha;  -- greek capital letter alpha
+ * U+0392 - &Beta;   -- greek capital letter beta
+ * U+0393 - &Gamma;  -- greek capital letter gamma
+ * U+0394 - &Delta;  -- greek capital letter delta
+ * U+0395 - &Epsilon; -- greek capital letter epsilon
+ * U+0396 - &Zeta;   -- greek capital letter zeta
+ * U+0397 - &Eta;    -- greek capital letter eta
+ * U+0398 - &Theta;  -- greek capital letter theta
+ * U+0399 - &Iota;   -- greek capital letter iota
+ * U+039A - &Kappa;  -- greek capital letter kappa
+ * U+039B - &Lambda; -- greek capital letter lambda
+ * U+039C - &Mu;     -- greek capital letter mu
+ * U+039D - &Nu;     -- greek capital letter nu
+ * U+039E - &Xi;     -- greek capital letter xi
+ * U+039F - &Omicron; -- greek capital letter omicron
+ * U+03A0 - &Pi;     -- greek capital letter pi
+ * U+03A1 - &Rho;    -- greek capital letter rho
+ * U+03A3 - &Sigma;  -- greek capital letter sigma
+ * U+03A4 - &Tau;    -- greek capital letter tau
+ * U+03A5 - &Upsilon; -- greek capital letter upsilon
+ * U+03A6 - &Phi;     -- greek capital letter phi
+ * U+03A7 - &Chi;     -- greek capital letter chi
+ * U+03A8 - &Psi;     -- greek capital letter psi
+ * U+03A9 - &Omega;   -- greek capital letter omega
+ * U+03B1 - &alpha;   -- greek small letter alpha
+ * U+03B2 - &beta;    -- greek small letter beta
+ * U+03B3 - &gamma;   -- greek small letter gamma
+ * U+03B4 - &delta;   -- greek small letter delta
+ * U+03B5 - &epsilon; -- greek small letter epsilon
+ * U+03B6 - &zeta;    -- greek small letter zeta
+ * U+03B7 - &eta;     -- greek small letter eta
+ * U+03B8 - &theta;   -- greek small letter theta
+ * U+03B9 - &iota;    -- greek small letter iota
+ * U+03BA - &kappa;   -- greek small letter kappa
+ * U+03BB - &lambda;  -- greek small letter lambda
+ * U+03BC - &mu;      -- greek small letter mu
+ * U+03BD - &nu;      -- greek small letter nu
+ * U+03BE - &xi;      -- greek small letter xi
+ * U+03BF - &omicron; -- greek small letter omicron
+ * U+03C0 - &pi;      -- greek small letter pi
+ * U+03C1 - &rho;     -- greek small letter rho
+ * U+03C2 - &sigmaf;  -- greek small letter final sigma
+ * U+03C3 - &sigma;   -- greek small letter sigma
+ * U+03C4 - &tau;     -- greek small letter tau
+ * U+03C5 - &upsilon; -- greek small letter upsilon
+ * U+03C6 - &phi;     -- greek small letter phi
+ * U+03C7 - &chi;     -- greek small letter chi
+ * U+03C8 - &psi;     -- greek small letter psi
+ * U+03C9 - &omega;   -- greek small letter omega
+ * U+03D1 - &thetasym; -- greek small letter theta symbol
+ * U+03D2 - &upsih;    -- greek upsilon with hook symbol
+ * U+03D6 - &piv;      -- greek pi symbol
+ *
+ * General Punctuation
+ * U+2022 - &bull;     -- bullet = black small circle
+ * U+2026 - &hellip;   -- horizontal ellipsis = three dot leader
+ * U+2032 - &prime;    -- prime = minutes = feet
+ * U+2033 - &Prime;    -- double prime = seconds = inches
+ * U+203E - &oline;    -- overline = spacing overscore
+ * U+2044 - &frasl;    -- fraction slash
+ *
+ * Letterlike Symbols
+ * U+2118 - &weierp;   -- script capital P = power set = Weierstrass p
+ * U+2111 - &image;    -- blackletter capital I = imaginary part
+ * U+211C - &real;     -- blackletter capital R = real part symbol
+ * U+2122 - &trade;    -- trade mark sign
+ * U+2135 - &alefsym;  -- alef symbol = first transfinite cardinal
+ *
+ * Arrows
+ * U+2190 - &larr;     -- leftwards arrow
+ * U+2191 - &uarr;     -- upwards arrow
+ * U+2192 - &rarr;     -- rightwards arrow
+ * U+2193 - &darr;     -- downwards arrow
+ * U+2194 - &harr;     -- left right arrow
+ * U+21B5 - &crarr;    -- downwards arrow with corner leftwards = carriage return
+ * U+21D0 - &lArr;     -- leftwards double arrow
+ * U+21D1 - &uArr;     -- upwards double arrow
+ * U+21D2 - &rArr;     -- rightwards double arrow
+ * U+21D3 - &dArr;     -- downwards double arrow
+ * U+21D4 - &hArr;     -- left right double arrow
+ *
+ * Mathematical Operators
+ * U+2200 - &forall;   -- for all
+ * U+2202 - &part;     -- partial differential
+ * U+2203 - &exist;    -- there exists
+ * U+2205 - &empty;    -- empty set = null set = diameter
+ * U+2207 - &nabla;    -- nabla = backward difference
+ * U+2208 - &isin;     -- element of
+ * U+2209 - &notin;    -- not an element of
+ * U+220B - &ni;       -- contains as member
+ * U+220F - &prod;     -- n-ary product = product sign
+ * U+2211 - &sum;      -- n-ary sumation
+ * U+2212 - &minus;    -- minus sign
+ * U+2217 - &lowast;   -- asterisk operator
+ * U+221A - &radic;    -- square root = radical sign
+ * U+221D - &prop;     -- proportional to
+ * U+221E - &infin;    -- infinity
+ * U+2220 - &ang;      -- angle
+ * U+2227 - &and;      -- logical and = wedge
+ * U+2228 - &or;       -- logical or = vee
+ * U+2229 - &cap;      -- intersection = cap
+ * U+222A - &cup;      -- union = cup
+ * U+222B - &int;      -- integral
+ * U+2234 - &there4;   -- therefore
+ * U+223C - &sim;      -- tilde operator = varies with = similar to
+ * U+2245 - &cong;     -- approximately equal to
+ * U+2248 - &asymp;    -- almost equal to = asymptotic to
+ * U+2260 - &ne;       -- not equal to
+ * U+2261 - &equiv;    -- identical to
+ * U+2264 - &le;       -- less-than or equal to
+ * U+2265 - &ge;       -- greater-than or equal to
+ * U+2282 - &sub;      -- subset of
+ * U+2283 - &sup;      -- superset of
+ * U+2284 - &nsub;     -- not a subset of
+ * U+2286 - &sube;     -- subset of or equal to
+ * U+2287 - &supe;     -- superset of or equal to
+ * U+2295 - &oplus;    -- circled plus = direct sum
+ * U+2297 - &otimes;   -- circled times = vector product
+ * U+22A5 - &perp;     -- up tack = orthogonal to = perpendicular
+ * U+22C5 - &sdot;     -- dot operator
+ *
+ * Miscellaneous Technical
+ * U+2308 - &lceil;    -- left ceiling = apl upstile
+ * U+2309 - &rceil;    -- right ceiling
+ * U+230A - &lfloor;   -- left floor = apl downstile
+ * U+230B - &rfloor;   -- right floor
+ * U+2329 - &lang;     -- left-pointing angle bracket = bra
+ * U+232A - &rang;     -- right-pointing angle bracket = ket
+ *
+ * Geometric Shapes
+ * U+25CA - &loz;      -- lozenge
+ *
+ * Miscellaneous Symbols
+ * U+2660 - &spades;   -- black spade suit
+ * U+2663 - &clubs;    -- black club suit = shamrock
+ * U+2665 - &hearts;   -- black heart suit = valentine
+ * U+2666 - &diams;    -- black diamond suit
+ *
+ * @copyright (c) 2004 The SquirrelMail development team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage strings
+ */
+?>
\ No newline at end of file
diff --git a/functions/htmlentities/utf-8.php b/functions/htmlentities/utf-8.php
new file mode 100644 (file)
index 0000000..5d806f0
--- /dev/null
@@ -0,0 +1,275 @@
+<?php
+/**
+ * utf-8 html entities table
+ *
+ * @copyright (c) 2004 The SquirrelMail development team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package squirrelmail
+ * @subpackage strings
+ */
+$sq_html_ent_table = array_merge($sq_html_ent_table,
+        array(// Latin1
+             "\xC2\xA0" => '&nbsp;',
+             "\xC2\xA1" => '&iexcl;',
+             "\xC2\xA2" => '&cent;',
+             "\xC2\xA3" => '&pound;',
+             "\xC2\xA4" => '&curren;',
+             "\xC2\xA5" => '&yen;',
+             "\xC2\xA6" => '&brvbar;',
+             "\xC2\xA7" => '&sect;',
+             "\xC2\xA8" => '&uml;',
+             "\xC2\xA9" => '&copy;',
+             "\xC2\xAA" => '&ordf;',
+             "\xC2\xAB" => '&laquo;',
+             "\xC2\xAC" => '&not;',
+             "\xC2\xAD" => '&shy;',
+             "\xC2\xAE" => '&reg;',
+             "\xC2\xAF" => '&macr;',
+             "\xC2\xB0" => '&deg;',
+             "\xC2\xB1" => '&plusmn;',
+             "\xC2\xB2" => '&sup2;',
+             "\xC2\xB3" => '&sup3;',
+             "\xC2\xB4" => '&acute;',
+             "\xC2\xB5" => '&micro;',
+             "\xC2\xB6" => '&para;',
+             "\xC2\xB7" => '&middot;',
+             "\xC2\xB8" => '&cedil;',
+             "\xC2\xB9" => '&sup1;',
+             "\xC2\xBA" => '&ordm;',
+             "\xC2\xBB" => '&raquo;',
+             "\xC2\xBC" => '&frac14;',
+             "\xC2\xBD" => '&frac12;',
+             "\xC2\xBE" => '&frac34;',
+             "\xC2\xBF" => '&iquest;',
+             "\xC3\x80" => '&Agrave;',
+             "\xC3\x81" => '&Aacute;',
+             "\xC3\x82" => '&Acirc;',
+             "\xC3\x83" => '&Atilde;',
+             "\xC3\x84" => '&Auml;',
+             "\xC3\x85" => '&Aring;',
+             "\xC3\x86" => '&AElig;',
+             "\xC3\x87" => '&Ccedil;',
+             "\xC3\x88" => '&Egrave;',
+             "\xC3\x89" => '&Eacute;',
+             "\xC3\x8A" => '&Ecirc;',
+             "\xC3\x8B" => '&Euml;',
+             "\xC3\x8C" => '&Igrave;',
+             "\xC3\x8D" => '&Iacute;',
+             "\xC3\x8E" => '&Icirc;',
+             "\xC3\x8F" => '&Iuml;',
+             "\xC3\x90" => '&ETH;',
+             "\xC3\x91" => '&Ntilde;',
+             "\xC3\x92" => '&Ograve;',
+             "\xC3\x93" => '&Oacute;',
+             "\xC3\x94" => '&Ocirc;',
+             "\xC3\x95" => '&Otilde;',
+             "\xC3\x96" => '&Ouml;',
+             "\xC3\x97" => '&times;',
+             "\xC3\x98" => '&Oslash;',
+             "\xC3\x99" => '&Ugrave;',
+             "\xC3\x9A" => '&Uacute;',
+             "\xC3\x9B" => '&Ucirc;',
+             "\xC3\x9C" => '&Uuml;',
+             "\xC3\x9D" => '&Yacute;',
+             "\xC3\x9E" => '&THORN;',
+             "\xC3\x9F" => '&szlig;',
+             "\xC3\xA0" => '&agrave;',
+             "\xC3\xA1" => '&aacute;',
+             "\xC3\xA2" => '&acirc;',
+             "\xC3\xA3" => '&atilde;',
+             "\xC3\xA4" => '&auml;',
+             "\xC3\xA5" => '&aring;',
+             "\xC3\xA6" => '&aelig;',
+             "\xC3\xA7" => '&ccedil;',
+             "\xC3\xA8" => '&egrave;',
+             "\xC3\xA9" => '&eacute;',
+             "\xC3\xAA" => '&ecirc;',
+             "\xC3\xAB" => '&euml;',
+             "\xC3\xAC" => '&igrave;',
+             "\xC3\xAD" => '&iacute;',
+             "\xC3\xAE" => '&icirc;',
+             "\xC3\xAF" => '&iuml;',
+             "\xC3\xB0" => '&eth;',
+             "\xC3\xB1" => '&ntilde;',
+             "\xC3\xB2" => '&ograve;',
+             "\xC3\xB3" => '&oacute;',
+             "\xC3\xB4" => '&ocirc;',
+             "\xC3\xB5" => '&otilde;',
+             "\xC3\xB6" => '&ouml;',
+             "\xC3\xB7" => '&divide;',
+             "\xC3\xB8" => '&oslash;',
+             "\xC3\xB9" => '&ugrave;',
+             "\xC3\xBA" => '&uacute;',
+             "\xC3\xBB" => '&ucirc;',
+             "\xC3\xBC" => '&uuml;',
+             "\xC3\xBD" => '&yacute;',
+             "\xC3\xBE" => '&thorn;',
+             "\xC3\xBF" => '&yuml;',
+             // Latin Extended-A
+             "\xC5\x92" => '&OElig;',
+             "\xC5\x93" => '&oelig;',
+             "\xC5\xA0" => '&Scaron;',
+             "\xC5\xA1" => '&scaron;',
+             "\xC5\xB8" => '&Yuml;',
+             // Spacing Modifier Letters
+             "\xCB\x86" => '&circ;',
+             "\xCB\x9C" => '&tilde;',
+             // General Punctuation
+             "\xE2\x80\x82" => '&ensp;',
+             "\xE2\x80\x83" => '&emsp;',
+             "\xE2\x80\x89" => '&thinsp;',
+             "\xE2\x80\x8C" => '&zwnj;',
+             "\xE2\x80\x8D" => '&zwj;',
+             "\xE2\x80\x8E" => '&lrm;',
+             "\xE2\x80\x8F" => '&rlm;',
+             "\xE2\x80\x93" => '&ndash;',
+             "\xE2\x80\x94" => '&mdash;',
+             "\xE2\x80\x98" => '&lsquo;',
+             "\xE2\x80\x99" => '&rsquo;',
+             "\xE2\x80\x9A" => '&sbquo;',
+             "\xE2\x80\x9C" => '&ldquo;',
+             "\xE2\x80\x9D" => '&rdquo;',
+             "\xE2\x80\x9E" => '&bdquo;',
+             "\xE2\x80\xA0" => '&dagger;',
+             "\xE2\x80\xA1" => '&Dagger;',
+             "\xE2\x80\xB0" => '&permil;',
+             "\xE2\x80\xB9" => '&lsaquo;',
+             "\xE2\x80\xBA" => '&rsaquo;',
+             "\xE2\x82\xAC" => '&euro;',
+             // Latin Extended-B
+             "\xC6\x92" => '&fnof;',
+             // Greek
+             "\xCE\x91" => '&Alpha;',
+             "\xCE\x92" => '&Beta;',
+             "\xCE\x93" => '&Gamma;',
+             "\xCE\x94" => '&Delta;',
+             "\xCE\x95" => '&Epsilon;',
+             "\xCE\x96" => '&Zeta;',
+             "\xCE\x97" => '&Eta;',
+             "\xCE\x98" => '&Theta;',
+             "\xCE\x99" => '&Iota;',
+             "\xCE\x9A" => '&Kappa;',
+             "\xCE\x9B" => '&Lambda;',
+             "\xCE\x9C" => '&Mu;',
+             "\xCE\x9D" => '&Nu;',
+             "\xCE\x9E" => '&Xi;',
+             "\xCE\x9F" => '&Omicron;',
+             "\xCE\xA0" => '&Pi;',
+             "\xCE\xA1" => '&Rho;',
+             "\xCE\xA3" => '&Sigma;',
+             "\xCE\xA4" => '&Tau;',
+             "\xCE\xA5" => '&Upsilon;',
+             "\xCE\xA6" => '&Phi;',
+             "\xCE\xA7" => '&Chi;',
+             "\xCE\xA8" => '&Psi;',
+             "\xCE\xA9" => '&Omega;',
+             "\xCE\xB1" => '&alpha;',
+             "\xCE\xB2" => '&beta;',
+             "\xCE\xB3" => '&gamma;',
+             "\xCE\xB4" => '&delta;',
+             "\xCE\xB5" => '&epsilon;',
+             "\xCE\xB6" => '&zeta;',
+             "\xCE\xB7" => '&eta;',
+             "\xCE\xB8" => '&theta;',
+             "\xCE\xB9" => '&iota;',
+             "\xCE\xBA" => '&kappa;',
+             "\xCE\xBB" => '&lambda;',
+             "\xCE\xBC" => '&mu;',
+             "\xCE\xBD" => '&nu;',
+             "\xCE\xBE" => '&xi;',
+             "\xCE\xBF" => '&omicron;',
+             "\xCF\x80" => '&pi;',
+             "\xCF\x81" => '&rho;',
+             "\xCF\x82" => '&sigmaf;',
+             "\xCF\x83" => '&sigma;',
+             "\xCF\x84" => '&tau;',
+             "\xCF\x85" => '&upsilon;',
+             "\xCF\x86" => '&phi;',
+             "\xCF\x87" => '&chi;',
+             "\xCF\x88" => '&psi;',
+             "\xCF\x89" => '&omega;',
+             "\xCF\x91" => '&thetasym;',
+             "\xCF\x92" => '&upsih;',
+             "\xCF\x96" => '&piv;',
+             // General Punctuation
+             "\xE2\x80\xA2" => '&bull;',
+             "\xE2\x80\xA6" => '&hellip;',
+             "\xE2\x80\xB2" => '&prime;',
+             "\xE2\x80\xB3" => '&Prime;',
+             "\xE2\x80\xBE" => '&oline;',
+             "\xE2\x81\x84" => '&frasl;',
+             // Letterlike Symbols
+             "\xE2\x84\x98" => '&weierp;',
+             "\xE2\x84\x91" => '&image;',
+             "\xE2\x84\x9C" => '&real;',
+             "\xE2\x84\xA2" => '&trade;',
+             "\xE2\x84\xB5" => '&alefsym;',
+             // Arrows
+             "\xE2\x86\x90" => '&larr;',
+             "\xE2\x86\x91" => '&uarr;',
+             "\xE2\x86\x92" => '&rarr;',
+             "\xE2\x86\x93" => '&darr;',
+             "\xE2\x86\x94" => '&harr;',
+             "\xE2\x86\xB5" => '&crarr;',
+             "\xE2\x87\x90" => '&lArr;',
+             "\xE2\x87\x91" => '&uArr;',
+             "\xE2\x87\x92" => '&rArr;',
+             "\xE2\x87\x93" => '&dArr;',
+             "\xE2\x87\x94" => '&hArr;',
+             // Mathematical Operators
+             "\xE2\x88\x80" => '&forall;',
+             "\xE2\x88\x82" => '&part;',
+             "\xE2\x88\x83" => '&exist;',
+             "\xE2\x88\x85" => '&empty;',
+             "\xE2\x88\x87" => '&nabla;',
+             "\xE2\x88\x88" => '&isin;',
+             "\xE2\x88\x89" => '&notin;',
+             "\xE2\x88\x8B" => '&ni;',
+             "\xE2\x88\x8F" => '&prod;',
+             "\xE2\x88\x91" => '&sum;',
+             "\xE2\x88\x92" => '&minus;',
+             "\xE2\x88\x97" => '&lowast;',
+             "\xE2\x88\x9A" => '&radic;',
+             "\xE2\x88\x9D" => '&prop;',
+             "\xE2\x88\x9E" => '&infin;',
+             "\xE2\x88\xA0" => '&ang;',
+             "\xE2\x88\xA7" => '&and;',
+             "\xE2\x88\xA8" => '&or;',
+             "\xE2\x88\xA9" => '&cap;',
+             "\xE2\x88\xAA" => '&cup;',
+             "\xE2\x88\xAB" => '&int;',
+             "\xE2\x88\xB4" => '&there4;',
+             "\xE2\x88\xBC" => '&sim;',
+             "\xE2\x89\x85" => '&cong;',
+             "\xE2\x89\x88" => '&asymp;',
+             "\xE2\x89\xA0" => '&ne;',
+             "\xE2\x89\xA1" => '&equiv;',
+             "\xE2\x89\xA4" => '&le;',
+             "\xE2\x89\xA5" => '&ge;',
+             "\xE2\x8A\x82" => '&sub;',
+             "\xE2\x8A\x83" => '&sup;',
+             "\xE2\x8A\x84" => '&nsub;',
+             "\xE2\x8A\x86" => '&sube;',
+             "\xE2\x8A\x87" => '&supe;',
+             "\xE2\x8A\x95" => '&oplus;',
+             "\xE2\x8A\x97" => '&otimes;',
+             "\xE2\x8A\xA5" => '&perp;',
+             "\xE2\x8B\x85" => '&sdot;',
+             // Miscellaneous Technical
+             "\xE2\x8C\x88" => '&lceil;',
+             "\xE2\x8C\x89" => '&rceil;',
+             "\xE2\x8C\x8A" => '&lfloor;',
+             "\xE2\x8C\x8B" => '&rfloor;',
+             "\xE2\x8C\xA9" => '&lang;',
+             "\xE2\x8C\xAA" => '&rang;',
+             // Geometric Shapes
+             "\xE2\x97\x8A" => '&loz;',
+             // Miscellaneous Symbols
+             "\xE2\x99\xA0" => '&spades;',
+             "\xE2\x99\xA3" => '&clubs;',
+             "\xE2\x99\xA5" => '&hearts;',
+             "\xE2\x99\xA6" => '&diams;'
+             )
+       );
+?>
\ No newline at end of file
index 157656a48c5a06084202c218de33ba690d5cbc7e..b2758608616049ae8e44d1c9f0e3296e50eb737b 100644 (file)
@@ -576,5 +576,85 @@ function sq_fwrite($fp, $string) {
        return $count;
 }
 
+/**
+ * sq_get_html_translation_table
+ *
+ * Returns the translation table used by sq_htmlentities()
+ *
+ * @param integer $table html translation table. Possible values (without quotes):
+ *                HTML_ENTITIES - full html entities table defined by charset
+ *                HTML_SPECIALCHARS - html special characters table
+ * @param integer $quote_style quote encoding style. Possible values (without quotes):
+ *                ENT_COMPAT - (default) encode double quotes
+ *                ENT_NOQUOTES -  don't encode double or single quotes
+ *                ENT_QUOTES - encode double and single quotes
+ * @param string $charset charset used for encoding. default to us-ascii, 'auto' uses $default_charset global value.
+ * @return array html translation array
+ */
+function sq_get_html_translation_table($table,$quote_style=ENT_COMPAT,$charset='us-ascii') {
+  global $default_charset;
+
+  if ($table == HTML_SPECIALCHARS) $charset='us-ascii';
+
+  // Start array with ampersand
+  $sq_html_ent_table = array( "&" => '&amp;' );
+
+  // < and >
+  $sq_html_ent_table = array_merge($sq_html_ent_table,
+                       array("<" => '&lt;',
+                             ">" => '&gt;')
+                       );
+  // double quotes
+  if ($quote_style == ENT_COMPAT)
+     $sq_html_ent_table = array_merge($sq_html_ent_table,
+                           array("\"" => '&quot;')
+                           );
+
+  // double and single quotes
+  if ($quote_style == ENT_QUOTES)
+     $sq_html_ent_table = array_merge($sq_html_ent_table,
+                           array("\"" => '&quot;',
+                             "'" => '&#39;')
+                           );
+
+  if ($charset=='auto') $charset=$default_charset;
+
+  // add entities that depend on charset
+  switch($charset){
+  case 'iso-8859-1':
+    include_once(SM_PATH . 'functions/htmlentities/iso-8859-1.php');
+    break;
+  case 'utf-8':
+    include_once(SM_PATH . 'functions/htmlentities/utf-8.php');
+    break;
+  case 'us-ascii':
+  default:
+    break;
+  }
+  // return table
+  return $sq_html_ent_table;
+}
+
+/**
+ * sq_htmlentities
+ *
+ * Convert all applicable characters to HTML entities.
+ * Minimal php requirement - v.4.0.5
+ *
+ * @param string $string string that has to be sanitized
+ * @param integer $quote_style quote encoding style. Possible values (without quotes):
+ *                ENT_COMPAT - (default) encode double quotes
+ *                ENT_NOQUOTES - don't encode double or single quotes
+ *                ENT_QUOTES - encode double and single quotes
+ * @param string $charset charset used for encoding. defaults to 'us-ascii', 'auto' uses $default_charset global value.
+ * @return string sanitized string
+ */
+function sq_htmlentities($string,$quote_style=ENT_COMPAT,$charset='us-ascii') {
+  // get translation table
+  $sq_html_ent_table=sq_get_html_translation_table(HTML_ENTITIES,$quote_style,$charset);
+  // convert characters
+  return str_replace(array_keys($sq_html_ent_table),array_values($sq_html_ent_table),$string);
+}
+
 $PHP_SELF = php_self();
 ?>
\ No newline at end of file