Hi

I made a notepad in Qt and I want to open the file I double-clicked on my app

I used app arguments (QCoreApplication::arguments()), the second argument is the file path

It works perfectly when the file name is in English but when the file name is in Arabic, there are some problems

sometimes when the file name is in Arabic, the argument looks like this:

C:/the/file/path/???????. txt

And I can't open the file

but sometimes it works with no problems for example when the file name is(????????) I got it like(????????), but when it is(??) or (?? ????) it works.

(When I open the file via QFileDialog, it works fine with any file name)

what is the problem and how can I fix it?

and thanks

main.cpp:

Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. #include <QApplication>
  4.  
  5. #include <QDebug>
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[])
  10.  
  11. {
  12.  
  13. QApplication a(argc, argv);
  14.  
  15. MainWindow w;
  16.  
  17. if(qApp->arguments().count() > 1)
  18.  
  19. w.openFile(qApp->arguments().at(1));
  20.  
  21. w.show();
  22.  
  23. return a.exec();
  24.  
  25. }
To copy to clipboard, switch view to plain text mode 

MainWindow::openFile(QString):

Qt Code:
  1. void MainWindow::openFile(QString URL)
  2.  
  3. {
  4.  
  5. QFile file(URL);
  6.  
  7. if(!file.open(QFile::ReadOnly | QFile::Text))
  8.  
  9. QMessageBox::warning(this, "Error, Can't open the file", file.errorString(), QMessageBox::Ok);
  10.  
  11. else
  12.  
  13. {
  14.  
  15. QTextStream text(&file);
  16.  
  17. text.setCodec("UTF-8");
  18.  
  19. QString fileContents = text.readAll();
  20.  
  21. TextEdit->setPlainText(fileContents);
  22.  
  23. file.close();
  24.  
  25. edited = false;
  26.  
  27. url = URL;
  28.  
  29. changeTitle();
  30.  
  31. }
  32.  
  33. }
To copy to clipboard, switch view to plain text mode