Chinese garbled code using node-ffi callback function

my code:

const ffi = require("ffi");
const ref = require("ref");

let ReadIdcard = ffi.Library("./ReadIdcard.dll", {
  "initReadIdcard": ["int", ["pointer"]]
});

let callback = ffi.Callback("void", ["string"],
  function(data) {
    console.log("data: ", data);
  });

console.log("registering the callback");
let z = ReadIdcard.initReadIdcard(callback);
console.log("done");

// Make an extra reference to the callback pointer to avoid GC
process.on("exit", function() {
  callback
});

DLL statement:

READIDCARD_API typedef void(*PIDDataCB)(char * pData);   

READIDCARD_API int initReadIdcard(PIDDataCB func);

32-bit DLL download:
Link: https://pan.baidu.com/s/1KcKl. password: g7d3

should be the problem of coding. When I try to transcode, I find that I can"t print Chinese normally. DLL is available. Chinese can be displayed normally by using local8bit conversion in QT.

clipboard.png

the following English sorry can be displayed normally

< hr >

in addition, when I learned that there is a module called fastcall, I wrote it and found that I didn"t seem to call

.
const fastcall = require("fastcall");
const Library = fastcall.Library;
const ref = fastcall.ref;

const lib = new Library("ReadIdcard.dll")
.callback({ PIDDataCB: ["void", ["string"]] })
.function({ initReadIdcard: ["int", ["PIDDataCB"]] });

function callback(data) {
  console.log("data: ", data);
};

lib.interface.initReadIdcard(callback);

ask the friends of the meeting to help find out what the problem is. No matter it is garbled or fastcall is used, thank you

first.
Mar.02,2021

function callback(data) {
  console.log("data: ", data);
};

can't I transcode in data?
iconv module


did the landlord solve this problem? Is it modified in dll or?

I wrote the dll, myself to process the Chinese characters in it and then output it to the ffi call.

  • Node-ffi calls cPP

    The code for cPP looks like this. How can I use ffi to call the Login method? typedef struct _LoginInfo{ LoginAuthType authType; char *username; char *userPassword; char *appKey; char *appToken; char *timestamp; char *...

    May.02,2022
Menu