PDA

View Full Version : Issue with coding in QString



luk_man_
12th August 2020, 09:03
Hello

I am facing with some issue and I don't have any idea how to fix that..
Generally, I want to use FIX API and the format should be like below:


"8=FIX.4.4|9=124|35=A|49=broker.1111111|56=server"

I noticed that it does not work in this format, but it works when I changed | sign to . Weird, but I think it is connected somehow with unicode coding...
In that that it was good and it worked.

Unfortunately, since some time, (I don't know why) the connection with the API does not work, because I noticed, the sent message does not look like:

"8=FIX.4.49=12435=A49=broker.111111156=server"
..but it looks:

Sending... "8=FIX.4.4\u00019=124\u000135=A\u000149=broker.1111 111\u000156=server

The sending code is below.

QString refMsg2 = "8=FIX.4.4|9=124|35=A|49=broker.1111111|56=server";
refMsg2.replace("|", "");
qDebug() << "Sending... " << refMsg2;
socket->write(refMsg2.toStdString().c_str());

The Question is: do you know whe I see "\u0001" now?

I think it does not work (there is no response from API) because write method of socket takes const char* argument and it changes something (there must be casting to stdString and call of c_str method)?


Do you have any ideas?
Thanks in advance!

Regards,
?ukasz

ChrisW67
12th August 2020, 13:16
The sending code is below.

QString refMsg2 = "8=FIX.4.4|9=124|35=A|49=broker.1111111|56=server";
refMsg2.replace("|", "");
qDebug() << "Sending... " << refMsg2;
socket->write(refMsg2.toStdString().c_str());

The Question is: do you know whe I see "\u0001" now?

The \u0001 is there because you have (somehow) typed the non-printable Control-A in the replacement string in line 2. Retype line 2.

Edit: On my machine the non-printable character became visible in the forum's advanced editor preview as a small, square placeholder character with 00 01 in it. YMMV