Link to home
Start Free TrialLog in
Avatar of JonMny
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
Avatar of jkr
jkr
Flag of Germany image

Hm, how do you obtain the file name? And how are you checking/printing it? "c:\هوoooooooooooooooहैFileName.mp4" for sure looks suspicious...
Avatar of JonMny
JonMny

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?
Avatar of JonMny

ASKER

yes
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JonMny

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हैFileName.mp4");
if ( f.exists() == false )