Unicode character to readable format
-
-
or... change the font that has control characters as visible characters.
I actually want this for Qt. That way I can see the trailing spaces at the end of a line of code.
Edit:
Found it!
In Qt Creator:
Options->Text Editor->Display(tab)->Visualize Whitespace -
Hi,
That's the catch: these are control characters, they don't have a visual representation. You will to replace them yourself with something if you want to make them "readable".
-
That's what we are trying to make you understand: they already are in your QString but they have no visual representation. If you print the length of your string you'll see that it's not empty. You can process that string for whatever you need but you can't print anything readable.
-
@eswar said in Unicode character to readable format:
I need to convert this Unicode to string (Readble format).
Please tell us:
- Why do you want to make the escape sequence "readable"?
- Which Readable Format do you want to use? (there are many possible readable formats)
- What do you want the final string to look like? Type it out for us.
-
Hi @JKSH
For your information, the application read the weighing scale data through serial port. if i ran the application same application in windows machine, i will get the correct data .
Refer the attached image (image url)
if i ran the application in the linux machine, i will get the escape sequence data only.
Refer image (link url) .
Both are same application screen shot with different machine. I dint know, Why it is behave in linux environment. If it is uni coded character in linux, i need to covert the character similar to the windows output. -
Hi
Check the sample code for receiving data in the serial port.
connect(port,&QSerialPort::readyRead,this,&WeighingMachine::readData);
buffer is QByteArray datatype.
void WeighingMachine::readData()
{
QString Time = QTime::currentTime().toString("hh:mm:ss.zzz");while(!(port->atEnd())) { buffer.append(port->readAll()); int i =0; QByteArray temp; int len = buffer.length();
#ifdef QT_DEBUG
qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
#endifwhile(i<len) { if ((buffer.at(i)== '\r') && (temp.length() > 0)) { QString str(temp); QString Find = "\n"; QString replace = ""; str.replace(str.indexOf(Find),Find.size(),replace); weighingMachineData = Time +"," +str;
#ifdef QT_DEBUG
// qDebug()<<"Weighing Data: "<<weighingMachineData;
#endiftemp.clear(); } else { temp.append(buffer.at(i)); } i++; } buffer.clear(); buffer.append(temp); temp.clear(); }
}
For your information, I also receive the same data in cutecom terminal also.
-
@eswar said in Unicode character to readable format:
#ifdef QT_DEBUG
qDebug()<<"Buffer: "<< QString::fromUtf8(buffer);;
#endifPlease change that to:
qDebug() << "Buffer:" << buffer << "hex:" << buffer.toHex();
and post the output here.Thanks.
-
@eswar That is really strange - all these characters are outside the visible ASCII range.
- Do you have a documentation for the command set of the device you are talking with?
- Can you repeat the last qDebug() tests in Windows?
- Are you sure the serial parameters (baudrate, start, stop bits, parity) are correct in Linux?
-
@eswar Something is terribly wrong in Linux - I'd blame the serial parameters.
You need to find the culprit before you can continue.
Best start with a terminal program in Linux and see if you can receive the data correctly there.
-