diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-24 18:02:06 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-24 18:02:06 -0700 |
commit | 2ec8c7a23fbc1adee266a1e9bf8ac3f24daf3663 (patch) | |
tree | cc8a5cd144e338322277f4f9e381a46a75b3e06b | |
parent | 323b01cf131118ddcd0aa641c5762526f8654edc (diff) | |
parent | 21efbaf73322c17a62ef28ea0df21515c67c5e2a (diff) |
Merge pull request #1629 from ngld/fix-ccallFunc-utf8
Fix ccallFunc to properly support UTF-8 strings
-rw-r--r-- | src/preamble.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/preamble.js b/src/preamble.js index 977ce004..183fd0c8 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -299,11 +299,10 @@ function ccallFunc(func, returnType, argTypes, args) { function toC(value, type) { if (type == 'string') { if (value === null || value === undefined || value === 0) return 0; // null string - if (!stack) stack = Runtime.stackSave(); - var ret = Runtime.stackAlloc(value.length+1); - writeStringToMemory(value, ret); - return ret; - } else if (type == 'array') { + value = intArrayFromString(value); + type = 'array'; + } + if (type == 'array') { if (!stack) stack = Runtime.stackSave(); var ret = Runtime.stackAlloc(value.length); writeArrayToMemory(value, ret); |