Closed beichen2012 closed 7 months ago
Currently, it seems that there is no out-of-the-box API in cxx to pass OsString from Rust to C++. You need to convert it to String:
let os = OsString::new();
let s = unsafe { String::from_utf8_unchecked(os.into_encoded_bytes()) };
Anyway, it's fallible to convert an OsString (not valid utf-8) to String in Rust.
So you can directly pass &[u8]
to C++ and then construct a std::string.
Thanks. Finally, Implemented by passing Vec[u8] from Rust to C++.
How to pass binary string (not valid utf-8 characters) from Rust to C++?