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. Is there a thrid lib can suppor soft decode music named chinese?
Forum Updated to NodeBB v4.3 + New Features

Is there a thrid lib can suppor soft decode music named chinese?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.0k 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.
  • chaochaoC Offline
    chaochaoC Offline
    chaochao
    wrote on last edited by
    #1

    Now , I use libzplay .But if the music named by chinese,libzplay will open failed.

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

      Hi! Are you sure libzplay cannot handle paths containing non ASCII characters? Did you try to find out what exactly was the problem? How are you handling the paths? What data type do you use for paths (char*, std::string, ...)?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      chaochaoC 1 Reply Last reply
      0
      • jsulmJ jsulm

        Hi! Are you sure libzplay cannot handle paths containing non ASCII characters? Did you try to find out what exactly was the problem? How are you handling the paths? What data type do you use for paths (char*, std::string, ...)?

        chaochaoC Offline
        chaochaoC Offline
        chaochao
        wrote on last edited by
        #3

        @jsulm my code is this. Whan I call player->open ,it will fail;

        QStringList fileNames=QFileDialog::getOpenFileNames(this,
        tr("Open file"),
        musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first(),
        tr("MP3 files (.mp3 .wav);;All files (.)"));

        foreach(QString file,fileNames)
        {
        QByteArray ba = file.toLocal8Bit();
        const char * name = ba.data();

         ZPlay *player = CreateZPlay();
        
         if(player->OpenFile(name, sfAutodetect) == 0)
             {
                 qDebug()<<QString("Error: %1 \nPress key to exit.\r\n").arg(player->GetError());
                // getch();
                 player->Release();
                 return false;
             }
        

        .......
        }

        jsulmJ 1 Reply Last reply
        0
        • chaochaoC chaochao

          @jsulm my code is this. Whan I call player->open ,it will fail;

          QStringList fileNames=QFileDialog::getOpenFileNames(this,
          tr("Open file"),
          musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first(),
          tr("MP3 files (.mp3 .wav);;All files (.)"));

          foreach(QString file,fileNames)
          {
          QByteArray ba = file.toLocal8Bit();
          const char * name = ba.data();

           ZPlay *player = CreateZPlay();
          
           if(player->OpenFile(name, sfAutodetect) == 0)
               {
                   qDebug()<<QString("Error: %1 \nPress key to exit.\r\n").arg(player->GetError());
                  // getch();
                   player->Release();
                   return false;
               }
          

          .......
          }

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @chaochao said in Is there a thrid lib can suppor soft decode music named chinese?:

          QByteArray ba = file.toLocal8Bit();

          Please read the documentation (http://doc.qt.io/qt-5/qstring.html#toLocal8Bit):
          "The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding."
          8bit encoding cannot represent Unicode!

          You have to use http://doc.qt.io/qt-5/qstring.html#toUtf8

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          chaochaoC 1 Reply Last reply
          0
          • jsulmJ jsulm

            @chaochao said in Is there a thrid lib can suppor soft decode music named chinese?:

            QByteArray ba = file.toLocal8Bit();

            Please read the documentation (http://doc.qt.io/qt-5/qstring.html#toLocal8Bit):
            "The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding."
            8bit encoding cannot represent Unicode!

            You have to use http://doc.qt.io/qt-5/qstring.html#toUtf8

            chaochaoC Offline
            chaochaoC Offline
            chaochao
            wrote on last edited by
            #5

            @jsulm I am very sorry to replay so late.
            when i use code QByteArray ba = filename.toUtf8(); const char * name = ba.data();, it is same erro.

            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