Results 1 to 4 of 4

Thread: Qt Ubuntu encoding of Characters

  1. #1
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt Ubuntu encoding of Characters

    Hello everyone,

    I've got the problem that Qt has a problem when I want to open a file from the command line with (I'm using Ubuntu)

    Qt Code:
    1. ./myapp /home/username/Arbeitsfläche/somefile
    To copy to clipboard, switch view to plain text mode 

    the problem is that Arbeitsfläche is read as: Arbeitsfläche and if I want to open it, that directory doesn't exist

    if I open the file with: QFileDialog::getOpenFileName, I get the correct string

    can someone help me out or point me in the right direction?

    thank you

    airglide

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Ubuntu encoding of Characters

    Quote Originally Posted by airglide View Post
    the problem is that Arbeitsfläche is read as
    Is read by whom? If you hardcoded the filename in your application, you need to tell Qt, what encoding you used (e.g. QString::fromUtf8()).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    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: Qt Ubuntu encoding of Characters

    QString::fromUtf8() will most likely work since most Linux systems have been using that codec for years now.
    Alternatively use QString::fromLocal8Bit() which uses the system's locale information to determine the currently used encoding

    Also have a look at QFile::decodeName()

    Cheers,
    _

  4. #4
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt Ubuntu encoding of Characters

    great, thanks to both of you, I used QString::fromLocal8Bit()

Similar Threads

  1. Qt on Ubuntu 10.04 from Ubuntu packages?
    By teele in forum Installation and Deployment
    Replies: 5
    Last Post: 28th March 2012, 08:41
  2. Encoding/Decoding and SQL
    By alexandernst in forum Qt Programming
    Replies: 0
    Last Post: 1st February 2011, 11:16
  3. encoding problem
    By lexqqq in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2010, 23:41
  4. QTextCodec bad encoding?
    By ComaWhite in forum Newbie
    Replies: 0
    Last Post: 18th September 2009, 06:15
  5. Encoding a QString to No.?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 30th August 2007, 19:08

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.