- var charAt = chars.charAt( i );\r
- table[ charAt ] = '&' + entities[ i ] + ';';\r
- regex.push( charAt );\r
+ // Transforms the entities string into an array.\r
+ entities = entities.split( ',' );\r
+\r
+ // Put all entities inside a DOM element, transforming them to their\r
+ // final chars.\r
+ var div = document.createElement( 'div' ),\r
+ chars;\r
+ div.innerHTML = '&' + entities.join( ';&' ) + ';';\r
+ chars = div.innerHTML;\r
+ div = null;\r
+\r
+ // Add all chars to the table.\r
+ for ( var i = 0 ; i < chars.length ; i++ )\r
+ {\r
+ var charAt = chars.charAt( i );\r
+ table[ charAt ] = '&' + entities[ i ] + ';';\r
+ regex.push( charAt );\r
+ }\r