Avoid dealing with QString::normalized when converting to and from std::string
-
wrote on 29 Oct 2021, 14:24 last edited by
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! -
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!wrote on 29 Oct 2021, 14:29 last edited by@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
-
@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
-
sure, that's what I am doing in my quoted code - but I'd love tell Qt to always apply this normalization
-
wrote on 29 Oct 2021, 15:35 last edited by
ok, too bad. Thanks for your help
1/5