Results 1 to 2 of 2

Thread: Issue with coding in QString

  1. #1
    Join Date
    May 2016
    Posts
    11
    Qt products
    Qt5

    Default Issue with coding in QString

    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=ser ver"
    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=ser ver"
    ..but it looks:
    Sending... "8=FIX.4.4\u00019=124\u000135=A\u000149=broker.111 1111\u000156=server
    The sending code is below.
    Qt Code:
    1. QString refMsg2 = "8=FIX.4.4|9=124|35=A|49=broker.1111111|56=server";
    2. refMsg2.replace("|", "");
    3. qDebug() << "Sending... " << refMsg2;
    4. socket->write(refMsg2.toStdString().c_str());
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,658
    Thanks
    13
    Thanked 1,594 Times in 1,522 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Issue with coding in QString

    Quote Originally Posted by luk_man_ View Post
    The sending code is below.
    Qt Code:
    1. QString refMsg2 = "8=FIX.4.4|9=124|35=A|49=broker.1111111|56=server";
    2. refMsg2.replace("|", "");
    3. qDebug() << "Sending... " << refMsg2;
    4. socket->write(refMsg2.toStdString().c_str());
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by ChrisW67; 12th August 2020 at 13:22.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Issue using QString
    By prophetjohn in forum Newbie
    Replies: 21
    Last Post: 28th June 2017, 18:40
  2. Replies: 1
    Last Post: 12th February 2016, 09:11
  3. Replies: 5
    Last Post: 13th May 2011, 00:02
  4. QString formatting issue.
    By George Neil in forum Qt Programming
    Replies: 2
    Last Post: 22nd October 2009, 09:00
  5. Replies: 0
    Last Post: 18th July 2009, 13:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.