Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Unicode on ES, files aren't shown in the correct encoding
QtWS25 Last Chance

Unicode on ES, files aren't shown in the correct encoding

Scheduled Pinned Locked Moved Solved Mobile and Embedded
unicodefilesystemfilebrowserutf-8embedded linux
8 Posts 3 Posters 3.3k 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.
  • Q Offline
    Q Offline
    QtEmbeddor
    wrote on last edited by
    #1

    Hi,

    I'm running a QML-Application on an embedded Linux.
    It provides file processing using QFile, QDir and QFileSystemWatcher (creating, reading, browsing). On Ubuntu Unicode works fine for the files. Creating different files work fine including foreign letters like Russian and umlauts (жю,äöü) but on the ES. it doesn't.

    • Files are not displayed correct, although Unicode in general works in the QT-App (the UI is available in Russian language)
    • Files created get file names like "201манÑ.txt"
    • Existing files are displayed like "201?????.txt"
    • Via SSH files are displayed by ls like "201?????.txt"
    • Via SSH the completion by <Tabkey> shows files correctly like "201датер.txt"
    • Via SSH typing echo <a string> shows the string my remote terminal like "???" the output of echo fine like датер. vi editor shows ..... and cat outputs датер.

    perhaps its not a QT-problem and more a Linux (file system) problem.
    No

     LANG=en_US.UTF-8 
    

    or similar is set but if I set it and restart the app nothing changes.
    Is a package missing that QT-Applications needs to work proper?

    Does someone have a solution or suggestion for that kind of problem?
    If that problem is unrelated to QT forgive me.

    J.HilkJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What is "ES" ? What Linux distribution are you running on it ? Do you have the same fonts as your desktop machine available on it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        ES=Embedded System. A Linux from scratch is running there so no known distro.
        Fonts are the same as on the desktop machine (Fira Sans). Fonts shouldn't be the problem since the whole gui is working in Russian and other languages having umlauts.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sorry, I misunderstood part of the problem.

          Do you know what encoding was used for the files you are trying to read ? Are they in UTF-8 or something else ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            QtEmbeddor
            wrote on last edited by QtEmbeddor
            #5

            It concerns only the encoding of file names.

            • files created using the QT-Application contain "?" instead of the not ASCII-Characters (really question marks). They are saved as names containing question marks.
            • files created in the terminal created like echo кзж > кзж are shown like "мÐ" in the QT-Application, as "???" by ls but auto completed in Cyrillic in console

            The Encoding inside the files works fine!

            Probably there is a library missing but which? I found this: The Program Uses or Creates Filenames in the Wrong Encoding which doesn't helped me but maybe concerns the same problem.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you share a small code sample creating a file with a failing name ? It will be easier to test.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Q QtEmbeddor

                Hi,

                I'm running a QML-Application on an embedded Linux.
                It provides file processing using QFile, QDir and QFileSystemWatcher (creating, reading, browsing). On Ubuntu Unicode works fine for the files. Creating different files work fine including foreign letters like Russian and umlauts (жю,äöü) but on the ES. it doesn't.

                • Files are not displayed correct, although Unicode in general works in the QT-App (the UI is available in Russian language)
                • Files created get file names like "201манÑ.txt"
                • Existing files are displayed like "201?????.txt"
                • Via SSH files are displayed by ls like "201?????.txt"
                • Via SSH the completion by <Tabkey> shows files correctly like "201датер.txt"
                • Via SSH typing echo <a string> shows the string my remote terminal like "???" the output of echo fine like датер. vi editor shows ..... and cat outputs датер.

                perhaps its not a QT-problem and more a Linux (file system) problem.
                No

                 LANG=en_US.UTF-8 
                

                or similar is set but if I set it and restart the app nothing changes.
                Is a package missing that QT-Applications needs to work proper?

                Does someone have a solution or suggestion for that kind of problem?
                If that problem is unrelated to QT forgive me.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @QtEmbeddor
                I'm assuming your local Codec is set wrong.

                E.g QTextStream uses by default the QTextCodec::codecForLocale(), but automatic unicode detection should be enabled as well.

                You could force unicode, to make sure:

                //Taken directely from the docu:
                QByteArray encodedString = "...";
                QTextCodec *codec = QTextCodec::codecForName("UTF-16");
                QString string = codec->toUnicode(encodedString);
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                2
                • Q Offline
                  Q Offline
                  QtEmbeddor
                  wrote on last edited by
                  #8

                  The solution to that problem is to insert the following call to the constructor of the file processing class:

                  QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
                  

                  Concerning the shell:
                  I use BusyBox (its light) which doesn't provide locale and the environment variables like LANG=en_US.UTF-8.
                  For compiling BusyBox configurations can or have to be given containing

                  CONFIG_LAST_SUPPORTED_WCHAR=0
                  

                  the number is the last displayable number of the Unicode list, 0 signifies that all characters shall be displayed, it was set to 767 which includes west European characters. The excluded characters are replaced by the character defined in the same configs, in my case it is "?".

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved