aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-07-14 20:44:35 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-07-14 20:44:35 -0700
commitd4a717b757e25cc1ef3adca912320d7a966e922d (patch)
tree9101ba2dcb74c9679c2760c24fb9f940441554fa
parent5fd21fc62fd407517ddfb0da706f7fcb757cf1be (diff)
make Pointer_stringify utf8-aware
-rw-r--r--src/preamble.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/preamble.js b/src/preamble.js
index ae00b796..777325c4 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -513,17 +513,17 @@ function allocate(slab, types, allocator) {
Module['allocate'] = allocate;
function Pointer_stringify(ptr, /* optional */ length) {
+ var utf8 = new Runtime.UTF8Processor();
var nullTerminated = typeof(length) == "undefined";
var ret = "";
var i = 0;
var t;
- var nullByte = String.fromCharCode(0);
while (1) {
- t = String.fromCharCode({{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}});
- if (nullTerminated && t == nullByte) { break; } else {}
- ret += t;
+ t = {{{ makeGetValue('ptr', 'i', 'i8', 0, 1) }}};
+ if (nullTerminated && t == 0) break;
+ ret += utf8.feed(t);
i += 1;
- if (!nullTerminated && i == length) { break; }
+ if (!nullTerminated && i == length) break;
}
return ret;
}