QT与单片机通讯汉字编码转换

QT在windows上输入汉字默认为GBK,用串口传输到单片机后必须转换为UTF-8

QString DevInfo = ui -> lineEdit_province->text();

QByteArray data = DevInfo.tolocal8Bit();

 std::string str = std::string(data);

const char *Dev_Info = str.c_str();

 

posted @ 2020-07-02 21:21  纯洁de小学生  阅读(389)  评论(0编辑  收藏  举报