Results 1 to 2 of 2

Thread: codec question

  1. #1
    Join Date
    Apr 2016
    Posts
    6
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Question codec question

    hello
    this time i like know how i can use character like Č,Ž,Švith codec? Im try change from Windows-1251 to ISO 8859-2 but i cant see Č,Ž,Š.

    My code: for to base 64
    spomin = ui->vnos->toPlainText();
    QString src = spomin;
    QTextCodec *codec = QTextCodec::codecForName("ISO 8859-2");
    QByteArray prevod = codec->fromUnicode(src);
    QByteArray text(prevod);
    beseda2 = text.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals); // returns "PHA+SGVsbG8/PC9wPg"
    ui->vnos->setText(beseda2);

    my code for from base 64
    spomin = ui->vnos->toPlainText();
    QString src = spomin;
    QTextCodec *codec = QTextCodec::codecForName("ISO 8859-2");
    QByteArray prevod = codec->fromUnicode(src);
    QByteArray text(prevod);
    beseda2=QByteArray::fromBase64(text, QByteArray::Base64Encoding);
    ui->vnos->setText(beseda2);

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: codec question

    Looks at this as a series of steps.

    Your "to base 64" series is
    - apply codec to transform unicode to ISO-8859-2
    - apply Base64 encoding

    Your "from base 64" should obviously be the steps in reverse, but instead they are
    - apply codec to transform unicode to ISO-8859-2
    - unapply base 64 encoding.

    So not only are you not applying the steps in the reverse order, you are applying one step twice and not its reverse.

    Cheers,
    _

Similar Threads

  1. Please help with codec in QSettings
    By lni in forum Qt Programming
    Replies: 3
    Last Post: 27th March 2014, 10:46
  2. QSettings Codec Problem
    By yaseminyilmaz in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2012, 15:00
  3. PyQt H265 Codec
    By blanchoir in forum Newbie
    Replies: 0
    Last Post: 3rd August 2011, 22:01
  4. Qt phonon and Codec
    By alexcuiCN in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2010, 08:56
  5. Retrieve string codec
    By Raccoon29 in forum Newbie
    Replies: 3
    Last Post: 26th January 2009, 21:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.