projects
/
g.raphael
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
295c1ea
)
faster replacement on unicode chars
author
Alan Knowles
<alan@roojs.com>
Wed, 16 Dec 2020 02:41:00 +0000
(10:41 +0800)
committer
Alan Knowles
<alan@roojs.com>
Wed, 16 Dec 2020 02:41:00 +0000
(10:41 +0800)
seed/toSVG.js
patch
|
blob
|
history
diff --git
a/seed/toSVG.js
b/seed/toSVG.js
index
7cdfcb7
..
1fb9180
100644
(file)
--- a/
seed/toSVG.js
+++ b/
seed/toSVG.js
@@
-282,19
+282,10
@@
function toSVG() {
svg += '</svg>';
- function U2A(str)
- {
- var ret = '';
- for (var i = 0;i < str.length; i++) {
- ret += str.charCodeAt(i) > 254 ? ('&#' + str.charCodeAt(i) + ';') : str.charAt(i);
- }
- return ret;
- }
+ return svg.replace(/[\u00A0-\u2666<>\&]/g, function(c) {
+ return '&#'+c.charCodeAt(0) + ';';
+ });
- return U2A(svg);
-
-
- return svg;
};
\ No newline at end of file