summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorYuriy Glukhov <yglukhov@users.noreply.github.com>2016-01-21 22:26:50 +0200
committerYuriy Glukhov <yglukhov@users.noreply.github.com>2016-01-21 22:26:50 +0200
commit5f092520d1f7df15910664d0555bf4c7db8b90d3 (patch)
tree44f4f6129cd9c8c79f9bcc7524cdb7123c070b3f /lib
parent1dac302975911752000e04fddb85b5302d7001b8 (diff)
downloadNim-5f092520d1f7df15910664d0555bf4c7db8b90d3.tar.gz
Revert "Fixed unicode handling in JS. Fixes #3714."
Diffstat (limited to 'lib')
-rw-r--r--lib/system/jssys.nim33
1 files changed, 7 insertions, 26 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index abee95f40..3df460952 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -166,33 +166,14 @@ proc SetConstr() {.varargs, asmNoStackFrame, compilerproc.} =
   """
 
 proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
-  {.emit: """
-  var ln = `c`.length;
-  var result = new Array(ln);
-  var r = 0;
-  for (var i = 0; i < ln; ++i) {
-    var ch = `c`.charCodeAt(i);
-
-    if (ch < 128) {
-      result[r] = ch;
-    }
-    else if((ch > 127) && (ch < 2048)) {
-      result[r] = (ch >> 6) | 192;
-      ++r;
-      result[r] = (ch & 63) | 128;
-    }
-    else {
-      result[r] = (ch >> 12) | 224;
-      ++r;
-      result[r] = ((ch >> 6) & 63) | 128;
-      ++r;
-      result[r] = (ch & 63) | 128;
+  asm """
+    var result = [];
+    for (var i = 0; i < `c`.length; ++i) {
+      result[i] = `c`.charCodeAt(i);
     }
-    ++r;
-  }
-  result[r] = 0; // terminating zero
-  return result;
-  """.}
+    result[result.length] = 0; // terminating zero
+    return result;
+  """
 
 proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} =
   asm """