Replace non-ASCII characters in recording filenames. #1437
Conversation
Replaces high-order Latin characters with their nearest ASCII equivalent for readability. Other non-ASCII chars are replaced with '_'. Fixes #1424
|
|
||
| for (auto &c : r) | ||
| { | ||
| c = (c >= 128) ? charmap[c - 128] : (c >= 32) ? c : '_'; |
hoffie
Apr 2, 2021
Member
Getting this with gcc 10.2.0:
src/recorder/jamrecorder.cpp: In member function 'QString recorder::CJamClient::TranslateChars(const QString&) const':
src/recorder/jamrecorder.cpp:125:16: warning: comparison is always false due to limited range of data type [-Wtype-limits]
125 | c = (c >= 128) ? charmap[c - 128] : (c >= 32) ? c : '_';
| ~~^~~~~~
In fact, German 'Ä' is replaced by '_' but I guess it was supposed to be replaced by 'A' in your logic?
Getting this with gcc 10.2.0:
src/recorder/jamrecorder.cpp: In member function 'QString recorder::CJamClient::TranslateChars(const QString&) const':
src/recorder/jamrecorder.cpp:125:16: warning: comparison is always false due to limited range of data type [-Wtype-limits]
125 | c = (c >= 128) ? charmap[c - 128] : (c >= 32) ? c : '_';
| ~~^~~~~~
In fact, German 'Ä' is replaced by '_' but I guess it was supposed to be replaced by 'A' in your logic?
softins
Apr 2, 2021
Author
Member
Ok, this must be a portability thing. On your system auto &c must be getting typed as signed char, whereas on mine it gets typed as unsigned char. That would be why on your system it never uses the array.
I could try it with unsigned char &c instead, but that might end up as a type mismatch. Or maybe just cast c to unsigned within the loop body.
No time on Sat to look at it, will do Sun or Mon. I see the Mac build failed too, so will have to see why.
Ok, this must be a portability thing. On your system auto &c must be getting typed as signed char, whereas on mine it gets typed as unsigned char. That would be why on your system it never uses the array.
I could try it with unsigned char &c instead, but that might end up as a type mismatch. Or maybe just cast c to unsigned within the loop body.
No time on Sat to look at it, will do Sun or Mon. I see the Mac build failed too, so will have to see why.
softins
Apr 2, 2021
Author
Member
I’ve pushed a change that hopefully might be portable. Let’s see.
I’ve pushed a change that hopefully might be portable. Let’s see.
hoffie
Apr 3, 2021
Member
No more warnings for me and Ä is proplery replaced with A. Looks good.
No more warnings for me and Ä is proplery replaced with A. Looks good.
|
If this is going to be done, it might as well remove all the nasties, rather than adding some -- specifically the ones that then get replaced: |
|
Should probably be squash-merged? |
Well the function of |
|
Unless you would prefer that |
If it's only going to be used in the one place, it might as well do it -- it'll be cheaper than the QRegExp, too, I expect. Yeah... |
664fd9e
into
jamulussoftware:master
Replaces high-order Latin characters with their nearest ASCII equivalent for readability.
Other non-ASCII chars are replaced with '_'.
Fixes #1424