I have a problem with strings and their encoding.

I have a struct which I simplify below with just one member and a function 
that should return a struct:
struct SomeStruct
{
    SomeStruct() {
        content = "content with different characters: ¼þþ®éþ";
    }
    std::string content;
};


SomeStruct getStruct()
{
    SomeStruct s;
    return s;
}

This is the struct and it is bound with following code

EMSCRIPTEN_BINDINGS() {

    value_object<SomeStruct>("SomeStruct")
        .field("content", &SomeStruct::content)
    ;

    function("getStruct", &getStruct);
}


When I call getStruct in Javascript this works but of course the problem is 
the special characters which turn into garbage.
How can I get around this problem that I can pass a string with 16bit and 
not 8. 

The following exported function works as expected after binding the 
function with cwrap. Is there something similar possible with structs?

extern "C"
{
    const char* getChar()
    {
        return "asdlþüúáæjfasf";
    }
}


-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to