简体   繁体   中英

conversion from ‘std::wstring {aka std::basic_string<wchar_t>}’ to non-scalar type ‘UString {aka std::basic_string<char>}’

Can you please tell me what's the wrong this code and Any ideas on how to fix?

JNIEXPORT jstring JNICALL Java_COM_DEMO_TEST_SEND (JNIEnv
*env, jclass c, jstring param){
    const char* strParam = env->GetStringUTFChars(param, 0);
    UString data = s2ws(string(strParam));
    UString result = TEST::SEND(data);
    return env->NewStringUTF(ws2s(result).c_str());
}

i got following error.

error: conversion from ‘std::wstring {aka std::basic_string<wchar_t>}’ to non-scalar type ‘UString {aka std::basic_string<char>}’ requested
  UString data = s2ws(string(strParam));

The error is pretty good, actually; you're trying to use a std::string but you have a std::wstring , and the compiler doesn't know how to convert one into the other.

The fact that they're both specializations of std::basic_string does not mean that they are interchangeable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM