Results 1 to 7 of 7

Thread: utf8 filenames / QDir::entryList

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Qt products
    Qt4
    Platforms
    Windows Android
    Thanks
    69
    Thanked 10 Times in 8 Posts

    Default Re: utf8 filenames / QDir::entryList

    Are you sure with Latin1 "U+00FC" ? For me it seems like Ã+00BC, with à being sort of an escape character.

    I've looked up the codes in this Utf8 table here. With that information I can just string-replace all Umlauts and other important chars. But for my case, it actually works as expected.

    This said, it's probably quite slow to tackle the problem this way, it seems like reassembling the debris instead of preventing the accident.


    Many thanks for the idea to actually look into the bytes myself - sometimes I don't see the wood for the trees. If anyone has a better idea (in terms of performance or safety of use), I'd be very happy to improve or entirely change my approach, but for the moment I can use that.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: utf8 filenames / QDir::entryList

    U+00FC is a Unicode code point for the character 'ü'. When encoded in UTF-8 that single Unicode character becomes 2 bytes 0xC3 0xBC.

    If you interpret those two bytes as Latin1 characters (which are always one byte-one char) you get, as you point out, Ã and ¼.

    So, the file name is encoded in UTF8 on the device. It is read as a set of bytes that are then incorrectly treated as a Latin1 string.

  3. The following user says thank you to ChrisW67 for this useful post:

    sedi (24th August 2013)

Similar Threads

  1. QDir::entryList() get absolute path
    By Aji Enrico in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2011, 04:26
  2. QDir - Entrylist, sort
    By bismitapadhy in forum Qt Programming
    Replies: 5
    Last Post: 28th January 2010, 06:27
  3. QDir entryList performing slowly
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2009, 16:21
  4. QDir::entryList() on linux
    By JeanC in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2008, 13:46
  5. qdir and entrylist
    By mattia in forum Newbie
    Replies: 1
    Last Post: 28th November 2007, 10:13

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.