Open evanhackett opened 5 years ago
I'm sorry, I can't answer this question. Reiner can. I don't know of any bug like this in the core library. Translating the string "1 2 3" using standard command line tools works fine, so it must be something in the JS bindings.
I can reproduce this using
npm install liblouis-build #liblouis-build@3.2.0-rc
npm install liblouis #liblouis 0.4.0
The progam crashes while trying to free memory of the output buffer of translateString. The issue does not occur if you use a utf32 build instead of a utf16 build:
<!doctype html>
<script src="node_modules/liblouis/easy-api.js"></script>
<script>
louAsync = new LiblouisEasyApiAsync({
easyapi: "node_modules/liblouis/easy-api.js",
capi: "node_modules/liblouis-build/build-no-tables-utf32.js"
});
louAsync.enableOnDemandTableLoading("node_modules/liblouis-build/tables/", function() {});
louAsync.setLogLevel(LiblouisEasyApi.prototype.LOG.ALL, function() {});
louAsync.registerLogCallback(function(logLevel, msg){
console.log(logLevel, msg);
});
louAsync.version(function(version) {
console.info("Liblouis Version:", version);
})
louAsync.translateString(
['unicode.dis', 'en-ueb-g2.ctb'].join(","),
'1 2 3', function(msg) { console.log("RESULT:", msg); }
);
</script>
produces:
Liblouis Version: 3.2.0
ALL Performing translation: tableList=unicode.dis,en-ueb-g2.ctb, inlen=24
ALL Inbuf=0x00000031 0x00000020 0x00000032 0x00000020 0x00000033 0x00000000 0x00000000 0x00000023 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000013 0x00000018 0x00000000 0x00000000 0x00000013 0x00000018 0x00000000 0x00000000 0x0000017B ~ 1 2 3
DEBUG found table unicode.dis
DEBUG found table en-ueb-g2.ctb
DEBUG found table en-ueb-g1.ctb
DEBUG found table en-ueb-chardefs.uti
DEBUG found table latinLetterDef8Dots.uti
DEBUG found table en-ueb-math.ctb
DEBUG found table braille-patterns.cti
ALL Translation complete: outlen=7
ALL Outbuf=0x0000283C 0x00002801 0x00002810 0x00002803 0x00002810 0x0000283C 0x00002809 ~
RESULT: ⠼⠁⠐⠃⠐⠼⠉
Using the 16bit build we get the correct result, but freeing the C memory of the result after copying it into Javascript fails:
Liblouis Version: 3.2.0
ALL Performing translation: tableList=unicode.dis,en-ueb-g2.ctb, inlen=12
ALL Inbuf=0x0031 0x0020 0x0032 0x0020 0x0033 0x0000 0x0013 0x0000 0x0000 0x0000 0x0000 0x0000 ~ 1 2 3
DEBUG found table unicode.dis
DEBUG found table en-ueb-g2.ctb
DEBUG found table en-ueb-g1.ctb
DEBUG found table en-ueb-chardefs.uti
DEBUG found table latinLetterDef8Dots.uti
DEBUG found table en-ueb-math.ctb
DEBUG found table braille-patterns.cti
ALL Translation complete: outlen=7
ALL Outbuf=0x283C 0x2801 0x2810 0x2803 0x2810 0x283C 0x2809 ~
I'm having issues translating simple strings that contain numbers and spaces. It is hard to identify a pattern regarding what exactly causes the error. One example is the string "1 2 3".
The above code has this output:
Oddly enough, the string "1 2" does work.
Any idea what could be causing this problem? Is this a known bug or a misuse of the api?
Thanks
Update: we tested the C liblouis library using the docker container referenced in the docs. The string "1 2 3" does indeed work with the C version, so this seems to be a problem specific to the javascript build.