Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. I want to get 3rd part softeware can decode music with no-ascll name such as chinese
Forum Updated to NodeBB v4.3 + New Features

I want to get 3rd part softeware can decode music with no-ascll name such as chinese

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
16 Posts 3 Posters 4.6k Views 3 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 am useing libzply. but when i open a music named by chinese ,libzplay will open err;

    bool LuoMusic::musicDecode(const QString &filename)
    {
      //  filename.toLocal8Bit()
      QByteArray ba  = filename.toUtf8();
      const char * name = ba.data();
       qDebug()<<name;
    
        ZPlay *player = CreateZPlay();
        if(player == 0)
          return false;
    
        int ver = player->GetVersion();
         // check if we have version 1.90 and above ( 1.90 if PF (pattent free) version, 2.00 version is full version
         if(ver < 190)
            {
                player->Release();
                return false;
            }
       //  qDebug()<<QString("libZPlay v.%1.%2i\r\n\r\n").arg(ver / 100).arg(ver % 100);
    
         if(player->OpenFile(name, sfAutodetect) == 0)
             {
                 qDebug()<<QString("Error: %1 \nPress key to exit.\r\n").arg(player->GetError());
                // getch();
                 player->Release();
                 return false;
             }
    }
    

    thank for your help

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

      Hi,

      What exact error your getting ?

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

      chaochaoC 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What exact error your getting ?

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

        @SGaist

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

        like this:
        Error: File open error. \nPress key to exit.\r\n

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

          What OS are you on ?

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

          chaochaoC 1 Reply Last reply
          0
          • SGaistS SGaist

            What OS are you on ?

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

            @SGaist windows 7

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

              now, i am useing libzply. but when i open a music named by chinese ,libzplay will open err;

              QByteArray ba  = filename.toUtf8();
              

              Are you sure your filename and paths are correct? Are your filenames written in UTF-8?

              Call qDebug() << QDir::current().entryList(). Is your file in the list?

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

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

                Since you are passing the path to an external library you should call QDir::toNativeSperators use the result to pass the path to player->OpenFile

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

                chaochaoC 1 Reply Last reply
                0
                • SGaistS SGaist

                  Since you are passing the path to an external library you should call QDir::toNativeSperators use the result to pass the path to player->OpenFile

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

                  @SGaist I did that ,but i got a same err. I think the problem is not this.Because when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.

                  JKSHJ 1 Reply Last reply
                  0
                  • chaochaoC chaochao

                    @SGaist I did that ,but i got a same err. I think the problem is not this.Because when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #9

                    @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

                    when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.

                    What encoding is your filename? UTF-8, or EUC-CN, or GB18030, or something else?

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    chaochaoC 1 Reply Last reply
                    1
                    • JKSHJ JKSH

                      @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

                      when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.

                      What encoding is your filename? UTF-8, or EUC-CN, or GB18030, or something else?

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

                      @JKSH filename get by QFileDialog::getOpenFileNames and convert to const char * by under code

                        QByteArray ba  = filename.toUtf8();
                        const char * name = ba.data();
                      

                      name will pass to OpenFile

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

                        What @JKSH is asking is not what you are using to decode the filename but how it is encoded by your OS.

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

                        chaochaoC 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          What @JKSH is asking is not what you are using to decode the filename but how it is encoded by your OS.

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

                          @SGaist GBK2312

                          JKSHJ 1 Reply Last reply
                          0
                          • chaochaoC chaochao

                            @SGaist GBK2312

                            JKSHJ Offline
                            JKSHJ Offline
                            JKSH
                            Moderators
                            wrote on last edited by JKSH
                            #13

                            @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

                            GBK2312

                            If your filename is not encoded in UTF-8, that means toUtf8() will give you the wrong path.

                            Try converting your filename to the GB2312, not UTF-8:

                            QTextCodec* codec = QTextCodec::codecForName("GB2312");
                            QByteArray ba = codec->fromUnicode(filename);
                            const char* name = ba.data();
                            

                            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                            chaochaoC 1 Reply Last reply
                            2
                            • JKSHJ JKSH

                              @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

                              GBK2312

                              If your filename is not encoded in UTF-8, that means toUtf8() will give you the wrong path.

                              Try converting your filename to the GB2312, not UTF-8:

                              QTextCodec* codec = QTextCodec::codecForName("GB2312");
                              QByteArray ba = codec->fromUnicode(filename);
                              const char* name = ba.data();
                              
                              chaochaoC Offline
                              chaochaoC Offline
                              chaochao
                              wrote on last edited by
                              #14

                              @JKSH as your code ,if i qDebug()<<name;

                              it will output
                              C:/Users/Public/Music/Sample Music/????.mp3

                              JKSHJ 1 Reply Last reply
                              0
                              • chaochaoC chaochao

                                @JKSH as your code ,if i qDebug()<<name;

                                it will output
                                C:/Users/Public/Music/Sample Music/????.mp3

                                JKSHJ Offline
                                JKSHJ Offline
                                JKSH
                                Moderators
                                wrote on last edited by
                                #15

                                @chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:

                                @JKSH as your code ,if i qDebug()<<name;

                                it will output
                                C:/Users/Public/Music/Sample Music/????.mp3

                                What do you see if you call qDebug() << ba?

                                Does zplay recognize this name?

                                What happens if you use Windows functions to get the filename? http://stackoverflow.com/questions/3176208/files-in-directory-in-c

                                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

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

                                  Don't forget you still need to first convert the path to native separators before passing it to your other library.

                                  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

                                  • Login

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