MCPcopy Create free account
hub / github.com/crawl/crawl / lowercase_first

Function lowercase_first

crawl-ref/source/stringutil.cc:88–97  ·  view source on GitHub ↗

Warning: this (and uppercase_first()) relies on no libc (glibc, BSD libc, MSVC crt) supporting letters that expand or contract, like German ß (-> SS) upon capitalization / lowercasing. This is mostly a fault of the API -- there's no way to return two characters in one code point. Also, all characters must have the same length in bytes before and after lowercasing, all platforms currently have this

Source from the content-addressed store, hash-verified

86// A non-hacky version would be slower for no gain other than sane code; at
87// least unless you use some more powerful API.
88string lowercase_first(string s)
89{
90 char32_t c;
91 if (!s.empty())
92 {
93 utf8towc(&c, &s[0]);
94 wctoutf8(&s[0], towlower(c));
95 }
96 return s;
97}
98
99string uppercase_first(string s)
100{

Callers 14

spell_uselessness_reasonFunction · 0.85
_get_move_verbFunction · 0.85
_weapon_ego_keyFunction · 0.85
_missile_ego_keyFunction · 0.85
_armour_ego_keyFunction · 0.85
describe.ccFile · 0.85
_nemelex_descFunction · 0.85
mut_upgrade_summaryFunction · 0.85
ouchFunction · 0.85
found_featureMethod · 0.85

Calls 3

utf8towcFunction · 0.85
wctoutf8Function · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected