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. LibTags special character
Qt 6.11 is out! See what's new in the release blog

LibTags special character

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.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.
  • UnitScanU Offline
    UnitScanU Offline
    UnitScan
    wrote on last edited by
    #1

    I have a this filename:
    "♥♫ Feels So Good (sonique Best Remix Extended Version) Music Song Video ❦ love romantic "

    Usually, to extract the file information I use this code

            QString mediafile = playlist->currentMedia().canonicalUrl().toString();
            QString tmp = mediafile.left(8) == "file:///" ? mediafile.mid(8) : mediafile;
            TagLib::FileRef f(QFile::encodeName(tmp).constData());
    

    This code works perfectly, only does not work when the file name contains special characters as above. I tried

    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    

    with no results.
    Any solution?

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

      Hi,

      You'll likely should convert the path to use native separators. Qt uses the *nix notation for paths so e.g. on Windows, you would have to convert the forward slashes to backward.

      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
      • UnitScanU Offline
        UnitScanU Offline
        UnitScan
        wrote on last edited by
        #3

        The problem lies in the filename, not in his path

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          try replacing QFile::encodeName(tmp) with tmp.toUtf8()

          also

          QString mediafile = playlist->currentMedia().canonicalUrl().toString();
                  QString tmp = mediafile.left(8) == "file:///" ? mediafile.mid(8) : mediafile;
          

          can become

          const QString tmp = playlist->currentMedia().canonicalUrl().toLocalFile();
          

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • UnitScanU Offline
            UnitScanU Offline
            UnitScan
            wrote on last edited by UnitScan
            #5

            [SOLVED]

            QString mediafile = playlist->currentMedia().canonicalUrl().toString();
            QString tmp = mediafile.left(8) == "file:///" ? mediafile.mid(8) : mediafile;
            TagLib::FileRef f(reinterpret_cast<const wchar_t*>(tmp.utf16()), true);
            
            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