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

DirectMemoryIO#getString(long, int, java.nio.charset.Charset) is broken for multi-byte encodings #166

Closed
pepijnve opened this issue Jun 6, 2018 · 2 comments

Comments

@pepijnve
Copy link
Contributor

pepijnve commented Jun 6, 2018

The implementation of this method uses com.kenai.jffi.MemoryIO#getZeroTerminatedByteArray(long, int) to get a byte array containing the string data. For various encodings, like UTF-16, this does not work correctly. The code actually needs to look for the representation of the 0 code point in the encoding in question instead of just looking for a single 0 valued byte.

@pepijnve
Copy link
Contributor Author

pepijnve commented Jun 7, 2018

While digging through the code this morning I was looking at jnr.ffi.provider.converters.StringResultConverter#fromNative. This implementation does do the right thing and takes terminator width into account.

@pepijnve
Copy link
Contributor Author

pepijnve commented Sep 3, 2018

Duplicate of #30

@pepijnve pepijnve closed this as completed Sep 3, 2018
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

1 participant