Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. [SOLVED]Qt 4.7 udpsocket and encoding issue

[SOLVED]Qt 4.7 udpsocket and encoding issue

Scheduled Pinned Locked Moved Brainstorm
3 Posts 2 Posters 2.9k 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.
  • 3 Offline
    3 Offline
    3lias
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      Hi,

      replied in the other post.

      T.

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

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

        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