Skip to content

Support for conversion between bytes and std::string #137

Answered by wjakob
brendan-ward asked this question in Q&A
Discussion options

You must be logged in to vote

A correction to what you said: commit #62 introduced a wrapper type (see this page for details: https://nanobind.readthedocs.io/en/latest/exchanging.html). What you ask for is a type converter that automatically casts std::string (or potentially, char * -- same thing) into bytes and vice versa. pybind11 really only supported this because of its Python 2.x heritage involving a mixture of byte and unicode-format strings. I don't actually think it's a good idea to do this anymore, and I am not eager to add support for it. My suggestion would be that you stay with pybind11, create a custom fork of nanobind, or adapt your own binding interface.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@brendan-ward
Comment options

Answer selected by brendan-ward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants