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. Dealing with character encoding - convert UTF8 to cp1252 ?
Forum Updated to NodeBB v4.3 + New Features

Dealing with character encoding - convert UTF8 to cp1252 ?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k Views 1 Watching
  • 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

    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";
    ledClient->sendText(text);
    @

    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->write(command))
    {
    if(socket->waitForBytesWritten(2000) && socket->waitForReadyRead((2000)))
    {
    socket->readAll();
    }
    }
    timer->start(timeout);
    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

    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