Skip to content

Commit 7545947

Browse files
committed
SimpCfg: Update the notes wrt tolower and add test code
1 parent 56ba758 commit 7545947

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

common/simpcfg.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,15 @@ TString str_trim_single(TString sin, const TString& trimChars=" \t\n") {
213213
return sin;
214214
}
215215

216-
// This works for NativeCharSize encoded chars, including in utf8 encoding space.
217-
// This wont work for multibyte encoded chars.
216+
// Convert to lower case, if language has upper and lower case semantic
217+
//
218+
// This works for fixed size encoded char spaces.
219+
//
220+
// For variable length encoded char spaces, it can work
221+
// * if one is doing the conversion for languages which fit into NativeCharSized chars in it
222+
// * AND if one is working with a sane variable length encoding standard
223+
// * ex: this will work if trying to do the conversion for english language within utf-8
224+
//
218225
template <typename TString>
219226
TString str_tolower(const TString &sin) {
220227
TString sout;
@@ -539,7 +546,8 @@ void check_nonenglish() {
539546
for (auto sTest: vTest1) {
540547
std::string sGotDumb = str_trim_dumb(sTest, {" \n\t"});
541548
std::string sGotOSmart = str_trim_oversmart(sTest, {" \n\t"});
542-
std::cout << std::format("{}: Test1[{}] Dumb[{}] OverSmart[{}]", __func__, sTest, sGotDumb, sGotOSmart) << std::endl;
549+
std::string sLower = str_tolower(sTest);
550+
std::cout << std::format("{}: Test1 [{}]\n\tTrimDumb[{}]\n\tTrimOverSmart[{}]\n\tLowerDumb[{}]", __func__, sTest, sGotDumb, sGotOSmart, sLower) << std::endl;
543551
}
544552
// The string "\n\tthis र remove 0s and अs at end 000रअ0\xa4अ ",
545553
// * will mess up str_trim_dumb,

0 commit comments

Comments
 (0)