diff options
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/runtime.js b/src/runtime.js index e39fa61e..6defbb35 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -334,10 +334,13 @@ var Runtime = { return Runtime.funcWrappers[func]; }, + // Returns a processor of UTF. + // processCChar() receives characters from a C-like UTF representation and returns JS string fragments. + // processJSString() receives a JS string and returns a C-like UTF representation in an array UTF8Processor: function() { var buffer = []; var needed = 0; - this.feed = function (code) { + this.processCChar = function (code) { code = code & 0xff; if (needed) { buffer.push(code); @@ -366,6 +369,14 @@ var Runtime = { buffer.length = 0; return ret; } + this.processJSString = function(string) { + string = unescape(encodeURIComponent(string)); + var ret = []; + for (var i = 0; i < string.length; i++) { + ret.push(string.charCodeAt(i)); + } + return ret; + } }, #if RUNTIME_DEBUG |