Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use GBK encoding #277

Open
seacdr opened this issue Nov 3, 2021 · 1 comment
Open

How to use GBK encoding #277

seacdr opened this issue Nov 3, 2021 · 1 comment

Comments

@seacdr
Copy link

seacdr commented Nov 3, 2021

The return string of my dynamic library is GBK coded
jna use System.setProperty("jna.encoding", "GBK"). success!
how can I read the correct return string?
thanks!

jnr code:

SSCardDriver_API libcSI = LibraryLoader.create(SSCardDriver_API.class).load("SSCardDriver");
StringBuffer pOutInfo = new StringBuffer(1024);
int nCode = libcSI.iReadCardBas(3, pOutInfo);
log.debug("{}=iReadCardBas({},{})", nCode, 3, pOutInfo.toString());

-11=iReadCardBas(3,���������Ӵ�)

jna code:

System.setProperty("jna.encoding", "GBK");
Pointer pOutInfo = new Memory(1024);
int nCode = SSCardDriver_Library.INSTANCE.iReadCardBas(3, pOutInfo);
log.debug("{}=iReadCardBas({},{})", nCode, 3, pOutInfo.getString(0));

-11=iReadCardBas(3,读卡器连接错)
@headius
Copy link
Member

headius commented Nov 22, 2021

Short term you will probably have to read raw bytes and decode them as GBK, but this should be fixed/improved.

Could you please provide an example piece of code that does not depend on this library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants