Dealing with character encoding - convert UTF8 to cp1252 ?

  • Hello,

    I am working on a software for controlling EPL 330 LED bars

    Everything seems to work : i can send command over TCP and have sentences displayed.

    The problem comes when i want to display characters with accents. I imagine character encoding can be the issue but i am not sure.

    In the EPL330 documentation, character encoding is CP437 or CP1252 (windows encoding). I think i need to use this one.

    How can i be sure that what i am sending respects this character encoding ?
    I am using TCPSocket::write() so i am send QByteArrays.

    For instance :

    • when i send "A\r\n" this displays "A" on the LED bar.
    • when i send "{A}\r\n" this displays "a" on the LED bar.
    • when i send "é\r\n" nothing happens...

    here is the code i use to create my text :

    QByteArray text = "é\r\n";

    here is the one that sends the message over TCP :

    bool TCPClient::sendText(QByteArray command)
    if (socket->state() != QAbstractSocket::ConnectedState)
    qWarning() << "Couldn't send command : not connected !";
    return false;
    if(socket->waitForBytesWritten(2000) && socket->waitForReadyRead((2000)))
    return true;

    Do you think this is a character encoding issue ? if yes, how can i fix it ?

    otherwise, what am i doing wrong ?

    thank you so much

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.