Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED]Qt 4.7 udpsocket and encoding issue

    Brainstorm
    2
    3
    2635
    Loading More Posts
    • 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.
    • 3
      3lias last edited by

      Hello,

      my name is ilias.I am studying Computers Science in Greece.This period i am composing my degree exercise which is about an automated system about students registration in my college.

      I have developed my application in two parts:
      1)the first one will be used on a small number of computers where someone will can go and fill the form for his registration(clients)
      2)the second one will be installed on a computer only("server") and it will be the computer which will receive the forms from computers where app 1 will be installed.

      My issue now:
      To application 2(server) i want to receive greek characters - that user would filled on their forms.I am using a QUdpSocket to do this but my problem will continue exist even if i change to QTcpSocket(i want to).

      the code tha application 1 use to send(to get data i use a vector<QString> where i have stored the fields tha user has complete)
      @
      for (int i = 0 ; i < 18 ; i++)
      {
      QByteArray datagram = array[i].toAscii();
      udpSocket->writeDatagram(datagram.data(), datagram.size(),QHostAddress::Broadcast, 45454);
      }
      @

      but the only thing i receive is something like "??????? ???? ???".

      the code that application 2 use to receive elements and store them in a vector<QString>
      @
      QByteArray datagram;
      datagram.resize(udpSocket->pendingDatagramSize());
      udpSocket->readDatagram(datagram.data(), datagram.size());

      array[cnt1][cnt2] = datagram.data();
      

      @

      I have tried to change the encoding of the element before send and after receiving with this function that i have made:
      @
      //Encoding transformation to greek 'windows-1253'
      QString MainWindow::transform_text(QByteArray temp)
      {
      QTextCodec *codec = QTextCodec::codecForName("Windows-1253");
      QString string = codec->toUnicode(temp);
      return string;
      }
      @
      but it didn't work.

      So, i am asking for your help about sending Greek Characters and receiving correct threw a QUdpSocket.
      For any information about i will be glad to answer.

      Best regards
      Ilias Pavlidakis
      3lias

      1 Reply Last reply Reply Quote 0
      • T
        tony last edited by

        Hi,

        replied in the other post.

        T.

        1 Reply Last reply Reply Quote 0
        • 3
          3lias last edited by

          Thank you very much.
          I try it the way you suggest me and worked perfectly :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post