0

我有一个 DLL,声明如下:

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

READIDCARD_API int initReadIdcard(PIDDataCB func);

DLL下载:<a href="https://drive.google.com/file/d/13JinraIr3N_6V_VrIfgHyB4_jW2V1s0f/view?usp=sharing" rel="nofollow noreferrer">32位dll文件(谷歌驱动下载)

dll文件运行良好,使用QT加载并转换数据时使用local8bit

我使用 node.js 和 node-ffi 来加载它

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
});

我的环境:Windows7 64bit / Node.js 32bit

运行代码,“sorry”字符串前的������˼��������是中文

在此处输入图像描述

我该怎么办,或者将其转换为显示正确,谢谢。

4

1 回答 1

0

您应该使用正确的编码来记录字符串。默认编码是utf8,但是中文应该是utf16/gb18030/gbk/gb2312这些之一。

于 2018-05-25T00:11:54.960 回答