Handling of Surrogate Pair Characters
-
Can I receive a file name with surrogate pair characters in the argument and open the file correctly with QFile, for example?
I'm having trouble with the surrogate pair characters being garbled as shown below."𩸽.txt" -> "??.txt"
// Run example. test.exe 𩸽.txt int main(int argc, char* argv[]) { QFile file(argv[1]); if (!file.open(QIODevice::WriteOnly)) { // open failed. } }
The following is environmental information.
- Windows 10
- Qt 5.15.5
-
You must not simply convert a char* to a QString - how should QString should know the enconding about the char*?
Use a Q(Core)Application and read the arguments from there - then they should be properly encoded. -
Thank you for your response.
You've been very helpful.