PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/files//1.2.1/string.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 751 lines | 668 code | 54 blank | 29 comment | 54 complexity | fddd2617039eb563c37a7604e1c6323a MD5 | raw file
  1. /*
  2. string.js - Copyright (C) 2012-2013, JP Richardson <jprichardson@gmail.com>
  3. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  4. associated documentation files (the "Software"), to deal in the Software without restriction, including
  5. without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  6. sell copies of the Software, and to permit persons to whom the Software is furnished to
  7. do so, subject to the following conditions:
  8. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  9. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  10. LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  11. THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  12. CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  13. DEALINGS IN THE SOFTWARE.
  14. */
  15. !(function() {
  16. "use strict";
  17. var VERSION = '1.2.1';
  18. function S(s) {
  19. if (s !== null && s !== undefined) {
  20. if (typeof s === 'string')
  21. this.s = s;
  22. else
  23. this.s = s.toString();
  24. } else {
  25. this.s = s; //null or undefined
  26. }
  27. this.orig = s; //original object, currently only used by toCSV() and toBoolean()
  28. if (s !== null && s !== undefined) {
  29. if (this.__defineGetter__) {
  30. this.__defineGetter__('length', function() {
  31. return this.s.length;
  32. })
  33. } else {
  34. this.length = s.length;
  35. }
  36. } else {
  37. this.length = -1;
  38. }
  39. }
  40. var __nsp = String.prototype;
  41. var __sp = S.prototype = {
  42. //# modified slightly from https://github.com/epeli/underscore.string
  43. camelize: function() {
  44. var s = this.trim().s.replace(/(\-|_|\s)+(.)?/g, function(mathc, sep, c) {
  45. return (c ? c.toUpperCase() : '');
  46. });
  47. return new S(s);
  48. },
  49. capitalize: function() {
  50. return new S(this.s.substr(0, 1).toUpperCase() + this.s.substring(1).toLowerCase());
  51. },
  52. charAt: function(index) {
  53. return this.s.charAt(index);
  54. },
  55. //#thanks Google
  56. collapseWhitespace: function() {
  57. var s = this.s.replace(/[\s\xa0]+/g, ' ').replace(/^\s+|\s+$/g, '');
  58. return new S(s);
  59. },
  60. contains: function(ss) {
  61. return this.s.indexOf(ss) >= 0;
  62. },
  63. //#modified from https://github.com/epeli/underscore.string
  64. dasherize: function() {
  65. var s = this.trim().s.replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
  66. return new S(s);
  67. },
  68. decodeHtmlEntities: function(quote_style) { //from php.js
  69. var symbol = "", entity = "", hash_map = {};
  70. var tmp_str = this.s;
  71. if (false === (hash_map = get_html_translation_table("HTML_ENTITIES", quote_style))) {
  72. return false;
  73. }
  74. delete hash_map["&"];
  75. hash_map["&"] = "&amp;";
  76. for (symbol in hash_map) {
  77. entity = hash_map[symbol];
  78. tmp_str = tmp_str.split(entity).join(symbol);
  79. }
  80. tmp_str = tmp_str.split("&#039;").join("'");
  81. return new S(tmp_str);
  82. },
  83. endsWith: function(suffix) {
  84. var l = this.s.length - suffix.length;
  85. return l >= 0 && this.s.indexOf(suffix, l) === l;
  86. },
  87. escapeHTML: function() { //from underscore.string
  88. return new S(this.s.replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; }));
  89. },
  90. isAlpha: function() {
  91. return !/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase());
  92. },
  93. isAlphaNumeric: function() {
  94. return !/[^0-9a-z\xC0-\xFF]/.test(this.s.toLowerCase());
  95. },
  96. isEmpty: function() {
  97. return this.s === null || this.s === undefined ? true : /^[\s\xa0]*$/.test(this.s);
  98. },
  99. isLower: function() {
  100. return this.isAlpha() && this.s.toLowerCase() === this.s;
  101. },
  102. isNumeric: function() {
  103. return !/[^0-9]/.test(this.s);
  104. },
  105. isUpper: function() {
  106. return this.isAlpha() && this.s.toUpperCase() === this.s;
  107. },
  108. left: function(N) {
  109. if (N >= 0) {
  110. var s = this.s.substr(0, N);
  111. return new S(s);
  112. } else {
  113. return this.right(-N);
  114. }
  115. },
  116. lines: function() {
  117. var lines = this.s.split('\n')
  118. for (var i = 0; i < lines.length; ++i) {
  119. lines[i] = lines[i].replace(/(^\s*|\s*$)/g, '');
  120. }
  121. return lines;
  122. },
  123. pad: function(len, ch) { //https://github.com/component/pad
  124. ch = ch || ' ';
  125. if (this.s.length >= len) return new S(this.s);
  126. len = len - this.s.length;
  127. var left = Array(Math.ceil(len / 2) + 1).join(ch);
  128. var right = Array(Math.floor(len / 2) + 1).join(ch);
  129. return new S(left + this.s + right);
  130. },
  131. padLeft: function(len, ch) { //https://github.com/component/pad
  132. ch = ch || ' ';
  133. if (this.s.length >= len) return new S(this.s);
  134. return new S(Array(len - this.s.length + 1).join(ch) + this.s);
  135. },
  136. padRight: function(len, ch) { //https://github.com/component/pad
  137. ch = ch || ' ';
  138. if (this.s.length >= len) return new S(this.s);
  139. return new S(this.s + Array(len - this.s.length + 1).join(ch));
  140. },
  141. parseCSV: function(delimiter, qualifier) { //try to parse no matter what
  142. delimiter = delimiter || ',';
  143. escape = '\\'
  144. if (typeof qualifier == 'undefined')
  145. qualifier = '"';
  146. var i = 0, fieldBuffer = [], fields = [], len = this.s.length, inField = false, self = this;
  147. var ca = function(i){return self.s.charAt(i)};
  148. if (!qualifier)
  149. inField = true;
  150. while (i < len) {
  151. var current = ca(i);
  152. switch (current) {
  153. case qualifier:
  154. if (!inField) {
  155. inField = true;
  156. } else {
  157. if (ca(i-1) === escape)
  158. fieldBuffer.push(current);
  159. else
  160. inField = false;
  161. }
  162. break;
  163. case delimiter:
  164. if (inField && qualifier)
  165. fieldBuffer.push(current);
  166. else {
  167. fields.push(fieldBuffer.join(''))
  168. fieldBuffer.length = 0;
  169. }
  170. break;
  171. case escape:
  172. if (qualifier)
  173. if (ca(i+1) !== qualifier)
  174. fieldBuffer.push(current);
  175. break;
  176. default:
  177. if (inField)
  178. fieldBuffer.push(current);
  179. break;
  180. }
  181. i += 1;
  182. }
  183. fields.push(fieldBuffer.join(''))
  184. return fields;
  185. },
  186. replaceAll: function(ss, r) {
  187. //var s = this.s.replace(new RegExp(ss, 'g'), r);
  188. var s = this.s.split(ss).join(r)
  189. return new S(s);
  190. },
  191. right: function(N) {
  192. if (N >= 0) {
  193. var s = this.s.substr(this.s.length - N, N);
  194. return new S(s);
  195. } else {
  196. return this.left(-N);
  197. }
  198. },
  199. slugify: function() {
  200. var sl = (new S(this.s.replace(/[^\w\s-]/g, '').toLowerCase())).dasherize().s;
  201. if (sl.charAt(0) === '-')
  202. sl = sl.substr(1);
  203. return new S(sl);
  204. },
  205. startsWith: function(prefix) {
  206. return this.s.lastIndexOf(prefix, 0) === 0;
  207. },
  208. stripPunctuation: function() {
  209. //return new S(this.s.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g,""));
  210. return new S(this.s.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " "));
  211. },
  212. stripTags: function() { //from sugar.js
  213. var s = this.s, args = arguments.length > 0 ? arguments : [''];
  214. multiArgs(args, function(tag) {
  215. s = s.replace(RegExp('<\/?' + tag + '[^<>]*>', 'gi'), '');
  216. });
  217. return new S(s);
  218. },
  219. template: function(values, opening, closing) {
  220. var s = this.s
  221. var opening = opening || Export.TMPL_OPEN
  222. var closing = closing || Export.TMPL_CLOSE
  223. var r = new RegExp(opening + '(.+?)' + closing, 'g')
  224. //, r = /\{\{(.+?)\}\}/g
  225. var matches = s.match(r) || [];
  226. console.log(opening)
  227. console.log(closing)
  228. matches.forEach(function(match) {
  229. var key = match.substring(opening.length, match.length - closing.length);//chop {{ and }}
  230. if (values[key])
  231. s = s.replace(match, values[key]);
  232. });
  233. return new S(s);
  234. },
  235. times: function(n) {
  236. return new S(new Array(n + 1).join(this.s));
  237. },
  238. toBoolean: function() {
  239. if (typeof this.orig === 'string') {
  240. var s = this.s.toLowerCase();
  241. return s === 'true' || s === 'yes' || s === 'on';
  242. } else
  243. return this.orig === true || this.orig === 1;
  244. },
  245. toFloat: function(precision) {
  246. var num = parseFloat(this.s, 10);
  247. if (precision)
  248. return parseFloat(num.toFixed(precision));
  249. else
  250. return num;
  251. },
  252. toInt: function() { //thanks Google
  253. // If the string starts with '0x' or '-0x', parse as hex.
  254. return /^\s*-?0x/i.test(this.s) ? parseInt(this.s, 16) : parseInt(this.s, 10);
  255. },
  256. trim: function() {
  257. var s;
  258. if (typeof String.prototype.trim === 'undefined') {
  259. s = this.s.replace(/(^\s*|\s*$)/g, '');
  260. } else {
  261. s = this.s.trim();
  262. }
  263. return new S(s);
  264. },
  265. trimLeft: function() {
  266. var s;
  267. if (__nsp.trimLeft)
  268. s = this.s.trimLeft();
  269. else
  270. s = this.s.replace(/(^\s*)/g, '');
  271. return new S(s);
  272. },
  273. trimRight: function() {
  274. var s;
  275. if (__nsp.trimRight)
  276. s = this.s.trimRight();
  277. else
  278. s = this.s.replace(/\s+$/, '');
  279. return new S(s);
  280. },
  281. truncate: function(length, pruneStr) { //from underscore.string, author: github.com/rwz
  282. var str = this.s;
  283. length = ~~length;
  284. pruneStr = pruneStr || '...';
  285. if (str.length <= length) return new S(str);
  286. var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
  287. template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
  288. if (template.slice(template.length-2).match(/\w\w/))
  289. template = template.replace(/\s*\S+$/, '');
  290. else
  291. template = new S(template.slice(0, template.length-1)).trimRight().s;
  292. return (template+pruneStr).length > str.length ? new S(str) : new S(str.slice(0, template.length)+pruneStr);
  293. },
  294. toCSV: function() {
  295. var delim = ',', qualifier = '"', escapeChar = '\\', encloseNumbers = true, keys = false;
  296. var dataArray = [];
  297. function hasVal(it) {
  298. return it !== null && it !== '';
  299. }
  300. if (typeof arguments[0] === 'object') {
  301. delim = arguments[0].delimiter || delim;
  302. delim = arguments[0].separator || delim;
  303. qualifier = arguments[0].qualifier || qualifier;
  304. encloseNumbers = !!arguments[0].encloseNumbers;
  305. escapeChar = arguments[0].escapeChar || escapeChar;
  306. keys = !!arguments[0].keys;
  307. } else if (typeof arguments[0] === 'string') {
  308. delim = arguments[0];
  309. }
  310. if (typeof arguments[1] === 'string')
  311. qualifier = arguments[1];
  312. if (arguments[1] === null)
  313. qualifier = null;
  314. if (this.orig instanceof Array)
  315. dataArray = this.orig;
  316. else { //object
  317. for (var key in this.orig)
  318. if (this.orig.hasOwnProperty(key))
  319. if (keys)
  320. dataArray.push(key);
  321. else
  322. dataArray.push(this.orig[key]);
  323. }
  324. var rep = escapeChar + qualifier;
  325. var buildString = [];
  326. for (var i = 0; i < dataArray.length; ++i) {
  327. var shouldQualify = hasVal(qualifier)
  328. if (typeof dataArray[i] == 'number')
  329. shouldQualify &= encloseNumbers;
  330. if (shouldQualify)
  331. buildString.push(qualifier);
  332. var d = new S(dataArray[i]).replaceAll(qualifier, rep).s;
  333. buildString.push(d);
  334. if (shouldQualify)
  335. buildString.push(qualifier);
  336. if (delim)
  337. buildString.push(delim);
  338. }
  339. //chop last delim
  340. //console.log(buildString.length)
  341. buildString.length = buildString.length - 1;
  342. return new S(buildString.join(''));
  343. },
  344. toString: function() {
  345. return this.s;
  346. },
  347. //#modified from https://github.com/epeli/underscore.string
  348. underscore: function() {
  349. var s = this.trim().s.replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
  350. if ((new S(this.s.charAt(0))).isUpper()) {
  351. s = '_' + s;
  352. }
  353. return new S(s);
  354. },
  355. unescapeHTML: function() { //from underscore.string
  356. return new S(this.s.replace(/\&([^;]+);/g, function(entity, entityCode){
  357. var match;
  358. if (entityCode in escapeChars) {
  359. return escapeChars[entityCode];
  360. } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
  361. return String.fromCharCode(parseInt(match[1], 16));
  362. } else if (match = entityCode.match(/^#(\d+)$/)) {
  363. return String.fromCharCode(~~match[1]);
  364. } else {
  365. return entity;
  366. }
  367. }));
  368. },
  369. valueOf: function() {
  370. return this.s.valueOf();
  371. }
  372. }
  373. var methodsAdded = [];
  374. function extendPrototype() {
  375. for (var name in __sp) {
  376. (function(name){
  377. var func = __sp[name];
  378. if (!__nsp.hasOwnProperty(name)) {
  379. methodsAdded.push(name);
  380. __nsp[name] = function() {
  381. String.prototype.s = this;
  382. return func.apply(this, arguments);
  383. }
  384. }
  385. })(name);
  386. }
  387. }
  388. function restorePrototype() {
  389. for (var i = 0; i < methodsAdded.length; ++i)
  390. delete String.prototype[methodsAdded[i]];
  391. methodsAdded.length = 0;
  392. }
  393. /*************************************
  394. /* Attach Native JavaScript String Properties
  395. /*************************************/
  396. var nativeProperties = getNativeStringProperties();
  397. for (var name in nativeProperties) {
  398. (function(name) {
  399. var stringProp = __nsp[name];
  400. if (typeof stringProp == 'function') {
  401. //console.log(stringProp)
  402. if (!__sp[name]) {
  403. if (nativeProperties[name] === 'string') {
  404. __sp[name] = function() {
  405. //console.log(name)
  406. return new S(stringProp.apply(this, arguments));
  407. }
  408. } else {
  409. __sp[name] = stringProp;
  410. }
  411. }
  412. }
  413. })(name);
  414. }
  415. /*************************************
  416. /* Function Aliases
  417. /*************************************/
  418. __sp.repeat = __sp.times;
  419. __sp.include = __sp.contains;
  420. __sp.toInteger = __sp.toInt;
  421. __sp.toBool = __sp.toBoolean;
  422. __sp.decodeHTMLEntities = __sp.decodeHtmlEntities //ensure consistent casing scheme of 'HTML'
  423. /*************************************
  424. /* Private Functions
  425. /*************************************/
  426. function getNativeStringProperties() {
  427. var names = getNativeStringPropertyNames();
  428. var retObj = {};
  429. for (var i = 0; i < names.length; ++i) {
  430. var name = names[i];
  431. var func = __nsp[name];
  432. try {
  433. var type = typeof func.apply('teststring', []);
  434. retObj[name] = type;
  435. } catch (e) {}
  436. }
  437. return retObj;
  438. }
  439. function getNativeStringPropertyNames() {
  440. var results = [];
  441. if (Object.getOwnPropertyNames) {
  442. results = Object.getOwnPropertyNames(__nsp);
  443. results.splice(results.indexOf('valueOf'), 1);
  444. results.splice(results.indexOf('toString'), 1);
  445. return results;
  446. } else { //meant for legacy cruft, this could probably be made more efficient
  447. var stringNames = {};
  448. var objectNames = [];
  449. for (var name in String.prototype)
  450. stringNames[name] = name;
  451. for (var name in Object.prototype)
  452. delete stringNames[name];
  453. //stringNames['toString'] = 'toString'; //this was deleted with the rest of the object names
  454. for (var name in stringNames) {
  455. results.push(name);
  456. }
  457. return results;
  458. }
  459. }
  460. function Export(str) {
  461. return new S(str);
  462. };
  463. //attach exports to StringJSWrapper
  464. Export.extendPrototype = extendPrototype;
  465. Export.restorePrototype = restorePrototype;
  466. Export.VERSION = VERSION;
  467. Export.TMPL_OPEN = '{{';
  468. Export.TMPL_CLOSE = '}}';
  469. /*************************************
  470. /* Exports
  471. /*************************************/
  472. if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
  473. module.exports = Export;
  474. } else {
  475. if(typeof define === "function" && define.amd) {
  476. define([], function() {
  477. return Export;
  478. });
  479. } else {
  480. window.S = Export;
  481. }
  482. }
  483. /*************************************
  484. /* 3rd Party Private Functions
  485. /*************************************/
  486. //from sugar.js
  487. function multiArgs(args, fn) {
  488. var result = [], i;
  489. for(i = 0; i < args.length; i++) {
  490. result.push(args[i]);
  491. if(fn) fn.call(args, args[i], i);
  492. }
  493. return result;
  494. }
  495. //from underscore.string
  496. var escapeChars = {
  497. lt: '<',
  498. gt: '>',
  499. quot: '"',
  500. apos: "'",
  501. amp: '&'
  502. };
  503. //from underscore.string
  504. var reversedEscapeChars = {};
  505. for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
  506. //from PHP.js
  507. function get_html_translation_table (table, quote_style) {
  508. var entities = {},
  509. hash_map = {},
  510. decimal;
  511. var constMappingTable = {},
  512. constMappingQuoteStyle = {};
  513. var useTable = {},
  514. useQuoteStyle = {};
  515. // Translate arguments
  516. constMappingTable[0] = 'HTML_SPECIALCHARS';
  517. constMappingTable[1] = 'HTML_ENTITIES';
  518. constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
  519. constMappingQuoteStyle[2] = 'ENT_COMPAT';
  520. constMappingQuoteStyle[3] = 'ENT_QUOTES';
  521. useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
  522. useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
  523. if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
  524. throw new Error("Table: " + useTable + ' not supported');
  525. // return false;
  526. }
  527. entities['38'] = '&amp;';
  528. if (useTable === 'HTML_ENTITIES') {
  529. entities['160'] = '&nbsp;';
  530. entities['161'] = '&iexcl;';
  531. entities['162'] = '&cent;';
  532. entities['163'] = '&pound;';
  533. entities['164'] = '&curren;';
  534. entities['165'] = '&yen;';
  535. entities['166'] = '&brvbar;';
  536. entities['167'] = '&sect;';
  537. entities['168'] = '&uml;';
  538. entities['169'] = '&copy;';
  539. entities['170'] = '&ordf;';
  540. entities['171'] = '&laquo;';
  541. entities['172'] = '&not;';
  542. entities['173'] = '&shy;';
  543. entities['174'] = '&reg;';
  544. entities['175'] = '&macr;';
  545. entities['176'] = '&deg;';
  546. entities['177'] = '&plusmn;';
  547. entities['178'] = '&sup2;';
  548. entities['179'] = '&sup3;';
  549. entities['180'] = '&acute;';
  550. entities['181'] = '&micro;';
  551. entities['182'] = '&para;';
  552. entities['183'] = '&middot;';
  553. entities['184'] = '&cedil;';
  554. entities['185'] = '&sup1;';
  555. entities['186'] = '&ordm;';
  556. entities['187'] = '&raquo;';
  557. entities['188'] = '&frac14;';
  558. entities['189'] = '&frac12;';
  559. entities['190'] = '&frac34;';
  560. entities['191'] = '&iquest;';
  561. entities['192'] = '&Agrave;';
  562. entities['193'] = '&Aacute;';
  563. entities['194'] = '&Acirc;';
  564. entities['195'] = '&Atilde;';
  565. entities['196'] = '&Auml;';
  566. entities['197'] = '&Aring;';
  567. entities['198'] = '&AElig;';
  568. entities['199'] = '&Ccedil;';
  569. entities['200'] = '&Egrave;';
  570. entities['201'] = '&Eacute;';
  571. entities['202'] = '&Ecirc;';
  572. entities['203'] = '&Euml;';
  573. entities['204'] = '&Igrave;';
  574. entities['205'] = '&Iacute;';
  575. entities['206'] = '&Icirc;';
  576. entities['207'] = '&Iuml;';
  577. entities['208'] = '&ETH;';
  578. entities['209'] = '&Ntilde;';
  579. entities['210'] = '&Ograve;';
  580. entities['211'] = '&Oacute;';
  581. entities['212'] = '&Ocirc;';
  582. entities['213'] = '&Otilde;';
  583. entities['214'] = '&Ouml;';
  584. entities['215'] = '&times;';
  585. entities['216'] = '&Oslash;';
  586. entities['217'] = '&Ugrave;';
  587. entities['218'] = '&Uacute;';
  588. entities['219'] = '&Ucirc;';
  589. entities['220'] = '&Uuml;';
  590. entities['221'] = '&Yacute;';
  591. entities['222'] = '&THORN;';
  592. entities['223'] = '&szlig;';
  593. entities['224'] = '&agrave;';
  594. entities['225'] = '&aacute;';
  595. entities['226'] = '&acirc;';
  596. entities['227'] = '&atilde;';
  597. entities['228'] = '&auml;';
  598. entities['229'] = '&aring;';
  599. entities['230'] = '&aelig;';
  600. entities['231'] = '&ccedil;';
  601. entities['232'] = '&egrave;';
  602. entities['233'] = '&eacute;';
  603. entities['234'] = '&ecirc;';
  604. entities['235'] = '&euml;';
  605. entities['236'] = '&igrave;';
  606. entities['237'] = '&iacute;';
  607. entities['238'] = '&icirc;';
  608. entities['239'] = '&iuml;';
  609. entities['240'] = '&eth;';
  610. entities['241'] = '&ntilde;';
  611. entities['242'] = '&ograve;';
  612. entities['243'] = '&oacute;';
  613. entities['244'] = '&ocirc;';
  614. entities['245'] = '&otilde;';
  615. entities['246'] = '&ouml;';
  616. entities['247'] = '&divide;';
  617. entities['248'] = '&oslash;';
  618. entities['249'] = '&ugrave;';
  619. entities['250'] = '&uacute;';
  620. entities['251'] = '&ucirc;';
  621. entities['252'] = '&uuml;';
  622. entities['253'] = '&yacute;';
  623. entities['254'] = '&thorn;';
  624. entities['255'] = '&yuml;';
  625. }
  626. if (useQuoteStyle !== 'ENT_NOQUOTES') {
  627. entities['34'] = '&quot;';
  628. }
  629. if (useQuoteStyle === 'ENT_QUOTES') {
  630. entities['39'] = '&#39;';
  631. }
  632. entities['60'] = '&lt;';
  633. entities['62'] = '&gt;';
  634. // ascii decimals to real symbols
  635. for (decimal in entities) {
  636. if (entities.hasOwnProperty(decimal)) {
  637. hash_map[String.fromCharCode(decimal)] = entities[decimal];
  638. }
  639. }
  640. return hash_map;
  641. };
  642. }).call(this);