Avoid dealing with QString::normalized when converting to and from std::string
Solved
General and Desktop
-
Hey,
I am struggling with a Third Party dependency that heavily relies on std::filesystem to do its thing.
When working with Qt 5.15.2 I always have to normalize my QStrings before passing them to the library. Apparently Qt uses a different default unicode normalization which is quite annoying.
Without normalization, Qt and the library detects some unicode characters quite different (e.g. the German character ä) making string comparison fail.So what I always have to do:
QString foo(QString string) { std::string stdString = string.normalized(QString::NormalizationForm_KD).toStdString(); std::string resultingString = _library->bar(stdString); return QString::fromStdString(resultingString).normalized(QString::NormalizationForm_KC); }
Is there a way to tell Qt to always normalize strings in a certain way?
Thanks a lot! -
@J0Nes said in Avoid dealing with QString::normalized when converting to and from std::string:
Is there a way to tell Qt to always normalize strings in a certain way?
Have a look yourself