Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] sending special character (escape) over TCP
Forum Update on Monday, May 27th 2025

[SOLVED] sending special character (escape) over TCP

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marty
    wrote on last edited by
    #1

    Hi,

    I am building an application to control hardware.
    The device waits for a string command over ethernet (TCP).

    example of command : escE1HDCP

    this is a command in string type with the character "escape" before.
    some others are plain string.

    i can have a string "E1HDCP" to be sent, but how can i send this "escape" character ?

    I use QString command type. Commands without this special character works without any issue.

    here is what i have so far :

    @bool Matrix::getHdcpStatus(QString input)
    {
    QString resp;
    resp = dxpClient->sendQuery("\27E" + input + "HDCP");
    return resp.toInt();
    }@

    thanks a lot.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      C++ string literals can contains escapes like "\nnn", where nnn is octal, or "\xnn", where nn is hexadecimal. Your string matches neither of these. The Escape character (decimal 27) is either "\033" or "\x1B".

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marty
        wrote on last edited by
        #3

        Hi,

        Thank you for your answers.
        Everything works now.

        Escape has the ascii code : 0x1B (hexa), 27 (decimal) or 033 (octal)

        So the command "escE1HDCP" in string type is :
        [code]
        "\x1BE1HDCP\r"
        [/code]

        Note : don't forget the return character (\r) at the end as suggested in the protocol.

        Thanks again

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved