Closed kiranshila closed 4 years ago
To add to this, the binary does in fact have those characters - which makes this even more strange to me
000d5a20: 756e 6374 696f 6e28 6129 7b72 6574 7572 unction(a){retur
000d5a30: 6e20 612a 612b 617d 3b n a*a+a};
So, I modified the binary and incremented the size by four by the header and it fixed the problem. Even stranger.
Huzzah! https://github.com/mfikes/esprit/blob/adf193769a16d48ca970fea377b37262dfeb7fff/src/esprit/make_rom.clj#L18 returns the number of characters, NOT the number of bytes.
I think there is some assumption in count
that there exists a fixed length encoding.
So on my machine,
(def js (slurp "out/main.js"))
(count js)
is not equal to
(count (.getBytes js))
And the latter matches the actual byte count
But then why is there non UTF-8 stuff in main.js :thinking:
Lol so compiling with advanced optimizations removes it, but with :simple
, it looks like there is some strange unicode in main.js
The two I found were
goog.string.Unicode={NBSP:" "}
and
goog.string.isUnicodeChar=function(a){return 1==a.length&&" "<=a&&"~">=a||""<=a&&"�">=a}
Ok, so this file has to be UTF-8 due to this. This makes sense as the web and JS is utf-8, so it would follow that espruino works with it. Alright so the solution is just ensuring we count the number of bytes correctly with .getBytes
PR inbound
As far as I can tell, every time I try to compile and load my own code (not writing code in the repl) the last four characters are getting lost somewhere.
I have a cljs file on the classpath like so
I build the project with
clj -m cljs.main -co {:optimizations :simple :target :none :browser-repl false :process-shim false} -c my-project.core
and build the rom and upload following your example.However, I get the error
The REPL does start and I can connect, but the
do-math
function is of course undefined.If I add more code to the cljs file, it always misses the last four characters - in this case
+a};