| 40 | |
| 41 | |
| 42 | string lowercase_string(const string &s) |
| 43 | { |
| 44 | string res; |
| 45 | char32_t c; |
| 46 | char buf[4]; |
| 47 | for (const char *tp = s.c_str(); int len = utf8towc(&c, tp); tp += len) |
| 48 | { |
| 49 | // crawl breaks horribly if this is allowed to affect ascii chars, |
| 50 | // so override locale-specific casing for ascii. (For example, in |
| 51 | // Turkish; tr_TR.utf8 lowercase I is a dotless i that is not |
| 52 | // ascii, which breaks many things.) |
| 53 | if (isaalpha(tp[0])) |
| 54 | res.append(1, toalower(tp[0])); |
| 55 | else |
| 56 | res.append(buf, wctoutf8(buf, towlower(c))); |
| 57 | } |
| 58 | return res; |
| 59 | } |
| 60 | |
| 61 | string &lowercase(string &s) |
| 62 | { |