Skip to content

UTF8ToString fails on specific strings #14786

@jeffRTC

Description

@jeffRTC

@sbc100 @kripken

This is a crazy one.

I pass Base64 strings like eyJuYW1lIjogIkphc29uIiwgImFnZSI6ICI0OCJ9 to JavaScript side.

Basically,

std::string text = "eyJuYW1lIjogIkphc29uIiwgImFnZSI6ICI0OCJ9";

// Call C-extern function
printSomething(text.c_str());

Now Javascript side try convert the pointer passed to JS function to UTF8 string using this way,

    printSomething: async function(pText) {
        let converted = UTF8ToString(pText);
        
        console.log(converted)
    }

But it returns an empty string as a result instead eyJuYW1lIjogIkphc29uIiwgImFnZSI6ICI0OCJ9.

I've ran the Javascript debugger over UTF8ToString and I find that it returns "\u0001" so for naked eye it's an empty string..

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