-
Notifications
You must be signed in to change notification settings - Fork 157
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
Please provide peekUTF8CString and withUTF8CString #32
Comments
Happy to consider this, if you've an idea of what the APIs should specifically look like. |
Same type signatures as peekCString and withCString, using the CString type, but accepting/producing UTF-8 respectively. |
That commit added the Len variants, but not the peekUTF8CString and withUTF8CString functions needed to work with the much more common NUL-terminated UTF-8. Could you please add that pair of functions as well? |
While here, document that `peekCStringLen`, `withCStringLen` are O(n) as well. Fixes haskell#32. Signed-off-by: Anders Kaseorg <[email protected]>
Since NUL-terminated CString is much more common in foreign APIs than CStringLen, one should not have to manually build these functions out of `peekCStringLen`, `withCStringLen` (and perhaps get it wrong, like I did in jgm/cmark-hs#13). While here, document that `peekCStringLen`, `withCStringLen` are O(n) as well. Fixes haskell#32. Signed-off-by: Anders Kaseorg <[email protected]>
Since NUL-terminated CString is much more common in foreign APIs than CStringLen, one should not have to manually build these functions out of `peekCStringLen`, `withCStringLen` (and perhaps get it wrong, like I did in jgm/cmark-hs#13). While here, document that `peekCStringLen`, `withCStringLen` are O(n) as well. Fixes haskell#32. Signed-off-by: Anders Kaseorg <[email protected]>
Since NUL-terminated CString is much more common in foreign APIs than CStringLen, one should not have to manually build these functions out of `peekCStringLen`, `withCStringLen` (and perhaps get it wrong, like I did in jgm/cmark-hs#13). While here, document that `withCStringLen` is O(n) as well. Fixes haskell#32. Signed-off-by: Anders Kaseorg <[email protected]>
Most UNIX APIs work in UTF-8, not UTF-16. Rather than having to write wrappers that encode/decode UTF-8 and run ByteString's packCString and useAsCString functions (and the corresponding ...Len variants), please consider providing these functions directly in either Data.Text.Foreign or Data.Text.Encoding. Such wrappers would make c2hs bindings easier to write.
The text was updated successfully, but these errors were encountered: