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. QFtp with unicode
Forum Updated to NodeBB v4.3 + New Features

QFtp with unicode

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 4.6k 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.
  • K Offline
    K Offline
    khend
    wrote on last edited by
    #1

    I am having trouble with QFtp and unicode file names. Everything looks fine up to where I call .put(), but when the file arrives at the destination, the name is a lot of question marks where the unicode characters are. (???? ????abc.xyz)

    Is this happening in the Qt call or is there something on the FTP server that isn't translating it correctly?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      How do you check the file name? What is the encoding of the filename? What encoding do you use when retrieving the data?

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        khend
        wrote on last edited by
        #3

        I was following along in the debugger (VS). I tried using toUTF8() and that seems to work with the server I am testing against, but we are not sure that this is reliable to use with any old FTP server out there.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mohsen
          wrote on last edited by
          #4

          Check your server's OS and web server application to make sure it allows unicode filenames on ftp.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franzk
            wrote on last edited by
            #5

            Exactly. The server will probably be fine, since the filename essentially is just a character array. It is the client you should worry about. If you really want to keep backwards compatibility with non-unicode clients, you should only allow ASCII names. Obviously this is starting to become less and less of an option.

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • K Offline
              K Offline
              khend
              wrote on last edited by
              #6

              The problem is that we have no control over the servers (user chooses it), and users have file names that work on their local systems in unicode. They may or may not be using the FTP option. I don't want to break something that works most of the time to have compatibility with only a few servers.

              Thanks for the replies - looks like I need to do more testing with different types of servers.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #7

                I'm not sure about the protocol itself, but I simply think QFtp is not Unicode-safe.

                See for instance

                • QFtp::put: http://qt.gitorious.com/qt/qt/blobs/master/src/network/access/qftp.cpp#line1875
                • which calls http://qt.gitorious.com/qt/qt/blobs/master/src/network/access/qftp.cpp#line2210
                • which calls http://qt.gitorious.com/qt/qt/blobs/master/src/network/access/qftp.cpp#line822
                • which calls http://qt.gitorious.com/qt/qt/blobs/master/src/network/access/qftp.cpp#line1143

                and the last line is
                @
                commandSocket.write(currentCmd.toLatin1());
                @

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Franzk
                  wrote on last edited by
                  #8

                  [quote author="khend" date="1294331766"]Thanks for the replies - looks like I need to do more testing with different types of servers.[/quote]Again, it is probably the clients that need checking. The servers are very likely to be ignorant of encoding (it really doesn't care which number represents which character).

                  In that line it is very likely that QFtp uses the toLocal8Bit, toAscii or codecForCStrings for the file transfer. You could try setting the latter to UTF-8, which should result in proper unicode strings on the other side. If that fails, try using QNetworkAccessManager instead of QFtp, which is the recommended thing to do anyway.

                  "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  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