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
C++Linux

Avatar of undefined
Last Comment
JonMny

8/22/2022 - Mon
jkr

Hm, how do you obtain the file name? And how are you checking/printing it? "c:\هوoooooooooooooooहैFileName.mp4" for sure looks suspicious...
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.

jkr

Does your application use UNICODE?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
JonMny

ASKER
yes
ASKER CERTIFIED SOLUTION
jkr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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 )