The developed terminal needs to be connected to two peripherals, and the second generation card reads the device and the printer.
The depressing thing is that the character encoding of the two devices is inconsistent with the terminal system, which took a lot of time at first and then noticed the problem of character encoding.
The data read from the second generation is encoded in Unicode, and the print child requires that the data in the past be converted to Unicode encoding.
Looking up the help document and finding that QT has its own transformation function, that's great.
The first is the data of the second generation of evidence:
QString Text = qtextcodec::codecforname ("GB2312")->fromunicode (str);
The terminal system uses the GB2312 code, and STR is a Unicode-encoded data buffer read from the second generation card.
This gets the text, it can be displayed on the terminal normally.
About the printer, on the contrary, it is asking us to transfer the data to Unicode:
Printbuf = Qtextcodec::codecforname ("GB2312")->tounicode ((text));
As for UTF-8 or other coding conversions, look at the QT help document.