UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

628 lines (550 loc) 26.4 kB
<!-- Generated by Rakefile:build --> <strong> <a href="http://an3m1.com/" rel="nofollow">????? ????</a> </strong> on 2012-04-23 14:51:17 <br /> If I might —perhaps you should consider adding a few images. I don’t mean to disrespect what you’ve said ; its very enlightening, indeed. However, I think would respond to it more positively if they could be something tangible to your ideas <hr /> <strong> Pitouli </strong> on 2011-06-14 14:52:26 <br /> A bigger list for replacement : <pre><code> entities['38'] = '&amp;amp;'; entities['60'] = '&amp;lt;'; entities['62'] = '&amp;gt;'; entities['94'] = '&amp;circ;'; entities['126'] = '&amp;tilde;'; entities['130'] = '&amp;sbquo;'; // Single Low-9 Quotation Mark entities['131'] = '&amp;fnof;'; // Latin Small Letter F With Hook entities['132'] = '&amp;bdquo;'; // Double Low-9 Quotation Mark entities['133'] = '&amp;hellip;'; // Horizontal Ellipsis entities['134'] = '&amp;dagger;'; // Dagger entities['135'] = '&amp;Dagger;'; // Double Dagger entities['136'] = '&amp;circ;'; // Modifier Letter Circumflex Accent entities['137'] = '&amp;permil;'; // Per Mille Sign entities['138'] = '&amp;Scaron;'; // Latin Capital Letter S With Caron entities['139'] = '&amp;lsaquo;'; // Single Left-Pointing Angle Quotation Mark entities['140'] = '&amp;OElig;'; // Latin Capital Ligature OE entities['145'] = '&amp;lsquo;'; // Left Single Quotation Mark entities['146'] = '&amp;rsquo;'; // Right Single Quotation Mark entities['147'] = '&amp;ldquo;'; // Left Double Quotation Mark entities['148'] = '&amp;rdquo;'; // Right Double Quotation Mark entities['149'] = '&amp;bull;'; // Bullet entities['150'] = '&amp;ndash;'; // En Dash entities['151'] = '&amp;mdash;'; // Em Dash entities['152'] = '&amp;tilde;'; // Small Tilde entities['153'] = '&amp;trade;'; // Trade Mark Sign entities['154'] = '&amp;scaron;'; // Latin Small Letter S With Caron entities['155'] = '&amp;rsaquo;'; // Single Right-Pointing Angle Quotation Mark entities['156'] = '&amp;oelig;'; // Latin Small Ligature OE entities['159'] = '&amp;Yuml;'; // Latin Capital Letter Y With Diaeresis entities['160'] = '&amp;nbsp;'; // Non-breaking space entities['161'] = '&amp;iexcl;'; // Inverted exclamation mark entities['162'] = '&amp;cent;'; // Cent sign entities['163'] = '&amp;pound;'; // Pound sign entities['164'] = '&amp;curren;'; // Currency sign entities['165'] = '&amp;yen;'; // Yen sign entities['166'] = '&amp;brvbar;'; // Broken vertical bar entities['167'] = '&amp;sect;'; // Section sign entities['168'] = '&amp;uml;'; // Diaeresis entities['169'] = '&amp;copy;'; // Copyright sign entities['170'] = '&amp;ordf;'; // Feminine ordinal indicator entities['171'] = '&amp;laquo;'; // Left-pointing double angle quotation mark entities['172'] = '&amp;not;'; // Not sign entities['173'] = '&amp;shy;'; // Soft hyphen entities['174'] = '&amp;reg;'; // Registered sign entities['175'] = '&amp;macr;'; // Macron entities['176'] = '&amp;deg;'; // Degree sign entities['177'] = '&amp;plusmn;'; // Plus-minus sign entities['178'] = '&amp;sup2;'; // Superscript two entities['179'] = '&amp;sup3;'; // Superscript three entities['180'] = '&amp;acute;'; // Acute accent entities['181'] = '&amp;micro;'; // Micro sign entities['182'] = '&amp;para;'; // Pilcrow sign entities['183'] = '&amp;middot;'; // Middle dot entities['184'] = '&amp;cedil;'; // Cedilla entities['185'] = '&amp;sup1;'; // Superscript one entities['186'] = '&amp;ordm;'; // Masculine ordinal indicator entities['187'] = '&amp;raquo;'; // Right-pointing double angle quotation mark entities['188'] = '&amp;frac14;'; // Vulgar fraction one-quarter entities['189'] = '&amp;frac12;'; // Vulgar fraction one-half entities['190'] = '&amp;frac34;'; // Vulgar fraction three-quarters entities['191'] = '&amp;iquest;'; // Inverted question mark entities['192'] = '&amp;Agrave;'; // A with grave entities['193'] = '&amp;Aacute;'; // A with acute entities['194'] = '&amp;Acirc;'; // A with circumflex entities['195'] = '&amp;Atilde;'; // A with tilde entities['196'] = '&amp;Auml;'; // A with diaeresis entities['197'] = '&amp;Aring;'; // A with ring above entities['198'] = '&amp;AElig;'; // AE entities['199'] = '&amp;Ccedil;'; // C with cedilla entities['200'] = '&amp;Egrave;'; // E with grave entities['201'] = '&amp;Eacute;'; // E with acute entities['202'] = '&amp;Ecirc;'; // E with circumflex entities['203'] = '&amp;Euml;'; // E with diaeresis entities['204'] = '&amp;Igrave;'; // I with grave entities['205'] = '&amp;Iacute;'; // I with acute entities['206'] = '&amp;Icirc;'; // I with circumflex entities['207'] = '&amp;Iuml;'; // I with diaeresis entities['208'] = '&amp;ETH;'; // Eth entities['209'] = '&amp;Ntilde;'; // N with tilde entities['210'] = '&amp;Ograve;'; // O with grave entities['211'] = '&amp;Oacute;'; // O with acute entities['212'] = '&amp;Ocirc;'; // O with circumflex entities['213'] = '&amp;Otilde;'; // O with tilde entities['214'] = '&amp;Ouml;'; // O with diaeresis entities['215'] = '&amp;times;'; // Multiplication sign entities['216'] = '&amp;Oslash;'; // O with stroke entities['217'] = '&amp;Ugrave;'; // U with grave entities['218'] = '&amp;Uacute;'; // U with acute entities['219'] = '&amp;Ucirc;'; // U with circumflex entities['220'] = '&amp;Uuml;'; // U with diaeresis entities['221'] = '&amp;Yacute;'; // Y with acute entities['222'] = '&amp;THORN;'; // Thorn entities['223'] = '&amp;szlig;'; // Sharp s. Also known as ess-zed entities['224'] = '&amp;agrave;'; // a with grave entities['225'] = '&amp;aacute;'; // a with acute entities['226'] = '&amp;acirc;'; // a with circumflex entities['227'] = '&amp;atilde;'; // a with tilde entities['228'] = '&amp;auml;'; // a with diaeresis entities['229'] = '&amp;aring;'; // a with ring above entities['230'] = '&amp;aelig;'; // ae. Also known as ligature ae entities['231'] = '&amp;ccedil;'; // c with cedilla entities['232'] = '&amp;egrave;'; // e with grave entities['233'] = '&amp;eacute;'; // e with acute entities['234'] = '&amp;ecirc;'; // e with circumflex entities['235'] = '&amp;euml;'; // e with diaeresis entities['236'] = '&amp;igrave;'; // i with grave entities['237'] = '&amp;iacute;'; // i with acute entities['238'] = '&amp;icirc;'; // i with circumflex entities['239'] = '&amp;iuml;'; // i with diaeresis entities['240'] = '&amp;eth;'; // eth entities['241'] = '&amp;ntilde;'; // n with tilde entities['242'] = '&amp;ograve;'; // o with grave entities['243'] = '&amp;oacute;'; // o with acute entities['244'] = '&amp;ocirc;'; // o with circumflex entities['245'] = '&amp;otilde;'; // o with tilde entities['246'] = '&amp;ouml;'; // o with diaeresis entities['247'] = '&amp;divide;'; // Division sign entities['248'] = '&amp;oslash;'; // o with stroke. Also known as o with slash entities['249'] = '&amp;ugrave;'; // u with grave entities['250'] = '&amp;uacute;'; // u with acute entities['251'] = '&amp;ucirc;'; // u with circumflex entities['252'] = '&amp;uuml;'; // u with diaeresis entities['253'] = '&amp;yacute;'; // y with acute entities['254'] = '&amp;thorn;'; // thorn entities['255'] = '&amp;yuml;'; // y with diaeresis entities['264'] = '&amp;#264;'; // Latin capital letter C with circumflex entities['265'] = '&amp;#265;'; // Latin small letter c with circumflex entities['338'] = '&amp;OElig;'; // Latin capital ligature OE entities['339'] = '&amp;oelig;'; // Latin small ligature oe entities['352'] = '&amp;Scaron;'; // Latin capital letter S with caron entities['353'] = '&amp;scaron;'; // Latin small letter s with caron entities['372'] = '&amp;#372;'; // Latin capital letter W with circumflex entities['373'] = '&amp;#373;'; // Latin small letter w with circumflex entities['374'] = '&amp;#374;'; // Latin capital letter Y with circumflex entities['375'] = '&amp;#375;'; // Latin small letter y with circumflex entities['376'] = '&amp;Yuml;'; // Latin capital letter Y with diaeresis entities['402'] = '&amp;fnof;'; // Latin small f with hook, function, florin entities['710'] = '&amp;circ;'; // Modifier letter circumflex accent entities['732'] = '&amp;tilde;'; // Small tilde entities['913'] = '&amp;Alpha;'; // Alpha entities['914'] = '&amp;Beta;'; // Beta entities['915'] = '&amp;Gamma;'; // Gamma entities['916'] = '&amp;Delta;'; // Delta entities['917'] = '&amp;Epsilon;'; // Epsilon entities['918'] = '&amp;Zeta;'; // Zeta entities['919'] = '&amp;Eta;'; // Eta entities['920'] = '&amp;Theta;'; // Theta entities['921'] = '&amp;Iota;'; // Iota entities['922'] = '&amp;Kappa;'; // Kappa entities['923'] = '&amp;Lambda;'; // Lambda entities['924'] = '&amp;Mu;'; // Mu entities['925'] = '&amp;Nu;'; // Nu entities['926'] = '&amp;Xi;'; // Xi entities['927'] = '&amp;Omicron;'; // Omicron entities['928'] = '&amp;Pi;'; // Pi entities['929'] = '&amp;Rho;'; // Rho entities['931'] = '&amp;Sigma;'; // Sigma entities['932'] = '&amp;Tau;'; // Tau entities['933'] = '&amp;Upsilon;'; // Upsilon entities['934'] = '&amp;Phi;'; // Phi entities['935'] = '&amp;Chi;'; // Chi entities['936'] = '&amp;Psi;'; // Psi entities['937'] = '&amp;Omega;'; // Omega entities['945'] = '&amp;alpha;'; // alpha entities['946'] = '&amp;beta;'; // beta entities['947'] = '&amp;gamma;'; // gamma entities['948'] = '&amp;delta;'; // delta entities['949'] = '&amp;epsilon;'; // epsilon entities['950'] = '&amp;zeta;'; // zeta entities['951'] = '&amp;eta;'; // eta entities['952'] = '&amp;theta;'; // theta entities['953'] = '&amp;iota;'; // iota entities['954'] = '&amp;kappa;'; // kappa entities['955'] = '&amp;lambda;'; // lambda entities['956'] = '&amp;mu;'; // mu entities['957'] = '&amp;nu;'; // nu entities['958'] = '&amp;xi;'; // xi entities['959'] = '&amp;omicron;'; // omicron entities['960'] = '&amp;pi;'; // pi entities['961'] = '&amp;rho;'; // rho entities['962'] = '&amp;sigmaf;'; // sigmaf entities['963'] = '&amp;sigma;'; // sigma entities['964'] = '&amp;tau;'; // tau entities['965'] = '&amp;upsilon;'; // upsilon entities['966'] = '&amp;phi;'; // phi entities['967'] = '&amp;chi;'; // chi entities['968'] = '&amp;psi;'; // psi entities['969'] = '&amp;omega;'; // omega entities['977'] = '&amp;thetasym;'; // Theta symbol entities['978'] = '&amp;upsih;'; // Greek upsilon with hook symbol entities['982'] = '&amp;piv;'; // Pi symbol entities['8194'] = '&amp;ensp;'; // En space entities['8195'] = '&amp;emsp;'; // Em space entities['8201'] = '&amp;thinsp;'; // Thin space entities['8204'] = '&amp;zwnj;'; // Zero width non-joiner entities['8205'] = '&amp;zwj;'; // Zero width joiner entities['8206'] = '&amp;lrm;'; // Left-to-right mark entities['8207'] = '&amp;rlm;'; // Right-to-left mark entities['8211'] = '&amp;ndash;'; // En dash entities['8212'] = '&amp;mdash;'; // Em dash entities['8216'] = '&amp;lsquo;'; // Left single quotation mark entities['8217'] = '&amp;rsquo;'; // Right single quotation mark entities['8218'] = '&amp;sbquo;'; // Single low-9 quotation mark entities['8220'] = '&amp;ldquo;'; // Left double quotation mark entities['8221'] = '&amp;rdquo;'; // Right double quotation mark entities['8222'] = '&amp;bdquo;'; // Double low-9 quotation mark entities['8224'] = '&amp;dagger;'; // Dagger entities['8225'] = '&amp;Dagger;'; // Double dagger entities['8226'] = '&amp;bull;'; // Bullet entities['8230'] = '&amp;hellip;'; // Horizontal ellipsis entities['8240'] = '&amp;permil;'; // Per mille sign entities['8242'] = '&amp;prime;'; // Prime entities['8243'] = '&amp;Prime;'; // Double Prime entities['8249'] = '&amp;lsaquo;'; // Single left-pointing angle quotation entities['8250'] = '&amp;rsaquo;'; // Single right-pointing angle quotation entities['8254'] = '&amp;oline;'; // Overline entities['8260'] = '&amp;frasl;'; // Fraction Slash entities['8364'] = '&amp;euro;'; // Euro sign entities['8472'] = '&amp;weierp;'; // Script capital entities['8465'] = '&amp;image;'; // Blackletter capital I entities['8476'] = '&amp;real;'; // Blackletter capital R entities['8482'] = '&amp;trade;'; // Trade mark sign entities['8501'] = '&amp;alefsym;'; // Alef symbol entities['8592'] = '&amp;larr;'; // Leftward arrow entities['8593'] = '&amp;uarr;'; // Upward arrow entities['8594'] = '&amp;rarr;'; // Rightward arrow entities['8595'] = '&amp;darr;'; // Downward arrow entities['8596'] = '&amp;harr;'; // Left right arrow entities['8629'] = '&amp;crarr;'; // Downward arrow with corner leftward. Also known as carriage return entities['8656'] = '&amp;lArr;'; // Leftward double arrow. ISO 10646 does not say that lArr is the same as the 'is implied by' arrow but also does not have any other character for that function. So ? lArr can be used for 'is implied by' as ISOtech suggests entities['8657'] = '&amp;uArr;'; // Upward double arrow entities['8658'] = '&amp;rArr;'; // Rightward double arrow. ISO 10646 does not say this is the 'implies' character but does not have another character with this function so ? rArr can be used for 'implies' as ISOtech suggests entities['8659'] = '&amp;dArr;'; // Downward double arrow entities['8660'] = '&amp;hArr;'; // Left-right double arrow // Mathematical Operators entities['8704'] = '&amp;forall;'; // For all entities['8706'] = '&amp;part;'; // Partial differential entities['8707'] = '&amp;exist;'; // There exists entities['8709'] = '&amp;empty;'; // Empty set. Also known as null set and diameter entities['8711'] = '&amp;nabla;'; // Nabla. Also known as backward difference entities['8712'] = '&amp;isin;'; // Element of entities['8713'] = '&amp;notin;'; // Not an element of entities['8715'] = '&amp;ni;'; // Contains as member entities['8719'] = '&amp;prod;'; // N-ary product. Also known as product sign. Prod is not the same character as U+03A0 'greek capital letter pi' though the same glyph might be used for both entities['8721'] = '&amp;sum;'; // N-ary summation. Sum is not the same character as U+03A3 'greek capital letter sigma' though the same glyph might be used for both entities['8722'] = '&amp;minus;'; // Minus sign entities['8727'] = '&amp;lowast;'; // Asterisk operator entities['8729'] = '&amp;#8729;'; // Bullet operator entities['8730'] = '&amp;radic;'; // Square root. Also known as radical sign entities['8733'] = '&amp;prop;'; // Proportional to entities['8734'] = '&amp;infin;'; // Infinity entities['8736'] = '&amp;ang;'; // Angle entities['8743'] = '&amp;and;'; // Logical and. Also known as wedge entities['8744'] = '&amp;or;'; // Logical or. Also known as vee entities['8745'] = '&amp;cap;'; // Intersection. Also known as cap entities['8746'] = '&amp;cup;'; // Union. Also known as cup entities['8747'] = '&amp;int;'; // Integral entities['8756'] = '&amp;there4;'; // Therefore entities['8764'] = '&amp;sim;'; // tilde operator. Also known as varies with and similar to. The tilde operator is not the same character as the tilde, U+007E, although the same glyph might be used to represent both entities['8773'] = '&amp;cong;'; // Approximately equal to entities['8776'] = '&amp;asymp;'; // Almost equal to. Also known as asymptotic to entities['8800'] = '&amp;ne;'; // Not equal to entities['8801'] = '&amp;equiv;'; // Identical to entities['8804'] = '&amp;le;'; // Less-than or equal to entities['8805'] = '&amp;ge;'; // Greater-than or equal to entities['8834'] = '&amp;sub;'; // Subset of entities['8835'] = '&amp;sup;'; // Superset of. Note that nsup, 'not a superset of, U+2283' is not covered by the Symbol font encoding and is not included. entities['8836'] = '&amp;nsub;'; // Not a subset of entities['8838'] = '&amp;sube;'; // Subset of or equal to entities['8839'] = '&amp;supe;'; // Superset of or equal to entities['8853'] = '&amp;oplus;'; // Circled plus. Also known as direct sum entities['8855'] = '&amp;otimes;'; // Circled times. Also known as vector product entities['8869'] = '&amp;perp;'; // Up tack. Also known as orthogonal to and perpendicular entities['8901'] = '&amp;sdot;'; // Dot operator. The dot operator is not the same character as U+00B7 middle dot // Miscellaneous Technical entities['8968'] = '&amp;lceil;'; // Left ceiling. Also known as an APL upstile entities['8969'] = '&amp;rceil;'; // Right ceiling entities['8970'] = '&amp;lfloor;'; // left floor. Also known as APL downstile entities['8971'] = '&amp;rfloor;'; // Right floor entities['9001'] = '&amp;lang;'; // Left-pointing angle bracket. Also known as bra. Lang is not the same character as U+003C 'less than'or U+2039 'single left-pointing angle quotation mark' entities['9002'] = '&amp;rang;'; // Right-pointing angle bracket. Also known as ket. Rang is not the same character as U+003E 'greater than' or U+203A 'single right-pointing angle quotation mark' // Geometric Shapes entities['9642'] = '&amp;#9642;'; // Black small square entities['9643'] = '&amp;#9643;'; // White small square entities['9674'] = '&amp;loz;'; // Lozenge // Miscellaneous Symbols entities['9702'] = '&amp;#9702;'; // White bullet entities['9824'] = '&amp;spades;'; // Black (filled) spade suit entities['9827'] = '&amp;clubs;'; // Black (filled) club suit. Also known as shamrock entities['9829'] = '&amp;hearts;'; // Black (filled) heart suit. Also known as shamrock entities['9830'] = '&amp;diams;'; // Black (filled) diamond suit </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-12-14 15:34:38 <br /> @ Nick Kolosov: Thanks for reporting. @ Fox: Thanks for fixing : ) Will be online shortly folks. <hr /> <strong> Fox </strong> on 2009-12-02 10:23:07 <br /> Sure it's not a good solution, but to answer to Nick Kolosov, and as I had the same problem with using : - htmlspecialchars =&gt; encode - html_entity_decode =&gt; decode And my aim was to not add parameters in functions (keep functions like php). I decided to add a small code in decode functions in order to fix the problem. in html_entity_decode function before : <pre><code> for (symbol in hash_map) { </code></pre> add the following lines : <pre><code> // BOF : fix &amp;amp; problem delete(hash_map['&amp;']); hash_map['&amp;'] = '&amp;amp;'; // EOF : fix &amp;amp; problem </code></pre> <hr /> <strong> <a href="http://sammy.ru" rel="nofollow">Nick Kolosov</a> </strong> on 2009-11-17 11:23:32 <br /> Ups, blog eated html tags. Error example: <pre><code> html_entity_decode('&amp;amp;nbsp;') = ' ' instead of '&amp;nbsp' </code></pre> <hr /> <strong> <a href="http://sammy.ru" rel="nofollow">Nick Kolosov</a> </strong> on 2009-11-17 11:09:51 <br /> Entities order must depend on the direction of translation. With conversion &lt;a&gt; =&gt; &amp;lt;a&gt; entities['38'] must be the first one. With conversion &amp;lt;a&gt; =&gt; &lt;a&gt; entities['38'] must be the last one. Current version with html_entity_decode converts &amp;amp;nbsp; to space instead of &amp;nbsp;. Its' wrong. May be html_entity_decode must be corrected, js is not my s trong side, don't know how to reverse hash order <hr /> <strong> <a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a> </strong> on 2009-10-20 20:06:18 <br /> @Roger: Yes, things can be that easy, if that's what you are trying to do. However, your function creating numeric character references has no relation to substituting for get_html_translation_table() for those who need it (nor for htmlentities() or htmlspecialchars() which depend on it). <hr /> <strong> Roger </strong> on 2009-10-20 16:51:08 <br /> Things can be so easy: <pre><code> function toHTMLEntity(str) { var s = str.split(&quot;&quot;); var ret = &quot;&quot;; for (i = 0; i &lt; s.length; i++) { var c = s[i].charCodeAt(0); if(c &gt; 127) ret += (&quot;&amp;#&quot; + c + &quot;;&quot;); else ret += s[i]; } return ret; } </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-07-08 16:34:24 <br /> Great stuff! <hr /> <strong> <a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a> </strong> on 2009-07-05 03:25:18 <br /> It was fixed recently in subversion (SVN). It just needed some time to be made available. Yes, it's true that ECMAScript doesn't guarantee the order of execution within objects, but I understand that all major browsers maintain the order (and PHP.JS in general depends on this, being as we rely on objects for associative array-like behavior). Good point about &quot;histogram&quot;. Maybe someone copied it from count_chars() which looks like that one used the word correctly. Anyways, I fixed it for the other functions (entity ones) where it was indeed not correct. <hr /> <strong> Ratheous </strong> on 2009-07-04 23:35:45 <br /> Because the ampersand is used in all entities, and htmlspecialchars etc. washes the string through the split and join repeatedly, entities['38'] should be the first item in the array and the first character replaced. Thus any ampersand already in the string will be correctly replaced but those introduced by the replacement of other characters will remain intact. Someone may have commented on this previously; it's hard to tell because the comments are a bit hard to follow, but regardless, it hasn't been fixed. Moving it up to line 40 solves the problem in my code, but if I remember correctly the use of for...in doesn't guarantee iterators in a particular order so it might be better to take it out of the entities table and replace it separately (though in my experience they come out in the order they were assigned). P.S. Just as an observation, you use 'histogram' as a variable name in a number of functions for what is actually a hash table... his?to?gram?/?h?st??græm/ –noun Statistics. a graph of a frequency distribution in which rectangles with bases on the horizontal axis are given widths equal to the class intervals and heights equal to the corresponding frequencies. <hr /> <strong> <a href="http://bahai-library.com" rel="nofollow">Brett Zamir</a> </strong> on 2009-04-30 09:27:22 <br /> Thanks... Done in SVN. I also simplified the if/else following <hr /> <strong> KELAN </strong> on 2009-04-30 07:55:27 <br /> useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; <hr /> <strong> KELAN </strong> on 2009-04-30 07:53:00 <br /> <pre><code> useTable = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS'); useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'); // Translate arguments constMappingTable[0] = 'HTML_SPECIALCHARS'; constMappingTable[1] = 'HTML_ENTITIES'; constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT'; constMappingQuoteStyle[3] = 'ENT_QUOTES'; // Map numbers to strings for compatibilty with PHP constants if (!isNaN(useTable)) { useTable = constMappingTable[useTable]; } if (!isNaN(useQuoteStyle)) { useQuoteStyle = constMappingQuoteStyle[useQuoteStyle]; } </code></pre> ==&gt; get_html_translation_table(0,2); <pre><code> constMappingTable[0] = 'HTML_SPECIALCHARS'; constMappingTable[1] = 'HTML_ENTITIES'; constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT'; constMappingQuoteStyle[3] = 'ENT_QUOTES'; useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS'; useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[table] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT'; </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-03-02 14:37:50 <br /> @ madipta: Thank you: fixed. <hr /> <strong> <a href="http://www.madipta.com" rel="nofollow">madipta</a> </strong> on 2009-02-26 02:56:45 <br /> i think you need to move entities['38'] on top <pre><code> entities['38'] = '&amp;amp;'; if (useQuoteStyle != 'ENT_NOQUOTES') { entities['34'] = '&amp;quot;'; } if (useQuoteStyle == 'ENT_QUOTES') { entities['39'] = '''; } </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-02-25 16:36:30 <br /> @ Marco: Excellent suggestion, thanks! <hr /> <strong> Marco </strong> on 2009-02-23 16:22:52 <br /> I suggest that you add a ; after the following code so that the script can be packed to one line (for example with: http://dean.edwards.name/packer/) <pre><code>symbol = String.fromCharCode(decimal)</code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-02-21 12:50:51 <br /> @ Alex: Ok I've changed it in SVN, can you tell me why is that? <hr /> <strong> Alex </strong> on 2009-02-20 13:09:05 <br /> need replace: entities['39'] = '&amp;amp;#039;'; to entities['39'] = '&amp;amp;#39;'; <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-12-01 09:34:04 <br /> @ GreLI: It was easier developing (read: copy &amp;amp; pasting ;) that way. We might want to switch back to reduce it's size though, that's a good point, thanks. <hr /> <strong> GreLI </strong> on 2008-11-30 16:39:50 <br /> Instead of this: <pre><code> entities['38'] = '&amp;amp;amp;amp;'; entities['60'] = '&amp;amp;amp;lt;'; entities['62'] = '&amp;amp;amp;gt;'; </code></pre> You can write <pre><code> entities = { '38': '&amp;amp;amp;amp;', '60': '&amp;amp;amp;lt;', '62': '&amp;amp;amp;gt;' } </code></pre> to reduce size and increase readability. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-11-03 10:23:51 <br /> @ noname: I've committed your fix noname, thanks! <hr /> <strong> noname </strong> on 2008-10-25 17:32:15 <br /> You need to change position for some lines. From: <pre><code> entities['60'] = '&amp;amp;lt;'; entities['62'] = '&amp;amp;gt;'; entities['38'] = '&amp;amp;amp;'; </code></pre> To: <pre><code> entities['38'] = '&amp;amp;amp;'; entities['60'] = '&amp;amp;lt;'; entities['62'] = '&amp;amp;gt;'; </code></pre> Because it will be encode wrong. Example: &amp;lt;a&amp;gt; =&amp;gt; &amp;amp;amp;lt;a&amp;amp;amp;gt; <hr />