JonMny
asked on
QT Qfile.exists returns false when existing file contains unicode chars
I have an application that uses QT c++ libs. One of the methods checks for the existance of a file before attempting to processes. The problem I have is the function returns false even when the file exists if there are unicode chars in the name.
The file name I am testing os
c:\هوoooooooooooooooà¤¹à ¥ˆFileName .mp4
The filename is passed as a command line arg
QFile fsrc(fileName);
if(!fsrc.exists()) //.exists() always returns false even if the file exists.
{
}
else
The file name I am testing os
c:\هوoooooooooooooooहà
The filename is passed as a command line arg
QFile fsrc(fileName);
if(!fsrc.exists()) //.exists() always returns false even if the file exists.
{
}
else
Hm, how do you obtain the file name? And how are you checking/printing it? "c:\هوoooooooooooooooह ैFileNam e.mp4" for sure looks suspicious...
ASKER
The name of the file was made with these "bad" characters deliberately by our QA team. So, the file does exist and the name is as it appears. The application writes the file name to a log file using this name and it does match.
Does your application use UNICODE?
ASKER
yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After looking at the code the .exists was in fact working. The application was calling an external application that was failing. The source file not found was a generic error that was thrown (regardless of the facts).
Thanks for the help for the record the code below works as expected.
QFile f("c:\هوoooooooooooooooà ¤¹à¥ˆFileN ame.mp4");
if ( f.exists() == false )
Thanks for the help for the record the code below works as expected.
QFile f("c:\هوoooooooooooooooà
if ( f.exists() == false )