实习记录犯错日志:
std::string utf8_str = gbk_to_utf8((char*)struCIDAlarmInfo.sCIDCode);
代码这样写则报如题所示的错误,error:connot bind non-const lvalue reference of type 'std::__cxx11::string& {aka std::cxx11::basic_string<char>&} to an rvalue of type 'std::__cxx11::string {aka std::__cxx11::basic_string<char>}‘,
代码修改为:std::string str = (char*)struCIDAlarmInfo.sCIDCode;
std::string utf8_str = gbk_to_utf8(str);
则不在报错,这是因为struCIDAlarmInfo.sCIDCode是unsigned char类型,需要转换为string类型,并且在转换的过程中需要用一个值去接这个类型,在传入gbk_to_utf8()中。
标签:std,__,cxx11,string,utf8,str From: https://blog.csdn.net/m0_52433622/article/details/139416748