Skip to content

RUST String convert to *const i8(c_char) compile to dll,FFI return error string, #73607

@kematy

Description

@kematy

fn convert(data:String)->*const i8
{
let ptr:*const u8=data.as_ptr();
let ptr:*const i8=ptr as *const i8;
//let _s=unsafe{*ptr};
ptr
}
inputstring :"JL/G1A-630/45_A"
outputstring:"JL/G1A-630/45_A8���T"
use data.as_ptr() as *const i8, got JL/G1A-630/45_A�We5���,
each time different
I wonder know why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions