Try converting your strings to Latin1 or utf-8 before doing the replace on the resulting QByteArray. Don't know if this will help. Character conversions and codepage issues can be very tricky.
Try converting your strings to Latin1 or utf-8 before doing the replace on the resulting QByteArray. Don't know if this will help. Character conversions and codepage issues can be very tricky.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Thanks for the answer d_stranz.
I don't want to make any change to the code because Qt4 under Windows DOES work as intended and also Qt5 under Linux. And I am not making anything fancy there. Just using the "QString::replace()" function and I expect it to behave like the documentation writes.
I just want to understand why Qt5-Windows behaves differently. Any clues?
BTW, the source file is ALWAYS in UTF8 (will add this to the first post, forgot about that).
OK, the problem seems to be the MSCV 2019 compiler.
I tried to use another kit today and added the MinGW 8.1.0 compiler along with Qt5 for windows. Result:
Windows 10 - Qt5 - MinGW output:
Qt Code:
----> ENTERING: void replaceStrings() === GOOD === str1: "[--,bb,AA,BB,--,bb,AA,BB]" str2: "[--,bb,AA,BB,--,bb,AA,BB]" ----> ENTERING: void replaceUmlauts() === GOOD === str1: "[--,??,÷÷,ÍÍ,³³,??,--,??,÷÷,ÍÍ,³³,??]" str2: "[--,??,÷÷,ÍÍ,³³,??,--,??,÷÷,ÍÍ,³³,??]"To copy to clipboard, switch view to plain text mode
So after really finding out who the bad guy was by trying to make a small program for you here, I also found out how to make him work as wanted.
Just add in your profile:
Qt Code:
QMAKE_CXXFLAGS += -source-charset:utf-8 QMAKE_CXXFLAGS += -execution-charset:utf-8To copy to clipboard, switch view to plain text mode
somewhere, along with any conditions you need and it works also good with MSCV 2019.
I hope this saves some time on everyone who encounters it!
Thanks and till next time!
freeman_w
Last edited by freeman_w; 16th September 2021 at 06:45.
d_stranz (16th September 2021)
Good detective work. Surprising to me that the compiler (or maybe the IDE) would let you type characters with umlauts as part of your source code and then mangle them when it built the code.QMAKE_CXXFLAGS += -source-charset:utf-8
QMAKE_CXXFLAGS += -execution-charset:utf-8
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks