diff options
-rw-r--r-- | lib/system/jssys.nim | 7 | ||||
-rw-r--r-- | web/community.txt | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 82cf18299..242f42c16 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -178,15 +178,18 @@ proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} = var asciiPart = new Array(len); var fcc = String.fromCharCode; var nonAsciiPart = null; + var nonAsciiOffset = 0; for (var i = 0; i < len; ++i) { if (nonAsciiPart !== null) { - nonAsciiPart[i * 2] = "%"; - nonAsciiPart[i * 2 + 1] = `s`[i].toString(16); + var offset = (i - nonAsciiOffset) * 2; + nonAsciiPart[offset] = "%"; + nonAsciiPart[offset + 1] = `s`[i].toString(16); } else if (`s`[i] < 128) asciiPart[i] = fcc(`s`[i]); else { asciiPart.length = i; + nonAsciiOffset = i; nonAsciiPart = new Array((len - i) * 2); --i; } diff --git a/web/community.txt b/web/community.txt index 12d024871..1348f7bec 100644 --- a/web/community.txt +++ b/web/community.txt @@ -78,6 +78,13 @@ Nim's Community When asking a question relating to Nim, be sure to use the `Nim <http://stackoverflow.com/questions/tagged/nim>`_ tag in your question. + +.. container:: standout + + Google+ + ------- + + The `G+ Nim community <https://plus.google.com/u/0/communities/106921341535068810587>`_ is another place where discussions related to the language happen. Read and follow various articles, posts and interesting links about Nim. .. container:: standout |