dfinity / node-motoko

Compile and run Motoko smart contracts in Node.js or the browser.
Apache License 2.0
15 stars 4 forks source link

Fix character encoding from moc.js interpreter #91

Closed rvanasa closed 5 months ago

rvanasa commented 5 months ago

This PR converts the ASCII strings returned from js_of_ocaml to the expected UTF-8 character set.

github-actions[bot] commented 5 months ago

size-limit report 📦

Path Size
lib/index.js 13.72 KB (+0.88% 🔺)
packages/latest/base.json 100.51 KB (0%)
versions/latest/moc.min.js 614.14 KB (0%)
versions/latest/moc_interpreter.min.js 296.54 KB (0%)
versions/latest/didc.min.js 63.78 KB (0%)
rvanasa commented 5 months ago

It's possible that upgrading js_of_ocaml to >= 5.1.0 could fix the issue based on this entry in the changelog:

  • Compiler: specialize string to js-string conversion for all valid utf8 strings (previously just ascii)

We're currently on 5.0.1 in the latest Motoko version. I'll open a PR to see if this fixes the issue.

rvanasa commented 5 months ago

@chenyan-dfinity, here's the PR: https://github.com/dfinity/motoko/pull/4493

Updating js_of_ocaml results in stack overflow errors (tried with 5.1.0 and 5.7.2). If necessary, we could maybe add this short-term fix in node-motoko and remove it once we're able to target newer versions of js_of_ocaml.

chenyan-dfinity commented 5 months ago

Sure, feel free to merge this.