13.11.2016, 11:42
Quote:
Вот функция дружит с упакованными строками и русским алфавитом:
Code:
stock ucfirst(string[]) { const dist = \'A\' - \'a\'; new i = strlen(string), c; if (string{0} != 0) { if (0xE0 <= (c = string{0}) <= 0xFF) string{0} += dist; else if (\'a\' <= c <= \'z\') string{0} += dist; do { if (0xC0 <= (c = string{i}) <= 0xDF) c -= dist; else if (\'A\' <= c <= \'Z\') c -= dist; string{i} = c; } while (--i != 0); } else { if (0xE0 <= (c = string[0]) <= 0xFF) string[0] += dist; else if (\'a\' <= c <= \'z\') string[0] += dist; do { if (0xC0 <= (c = string[i]) <= 0xDF) c -= dist; else if (\'A\' <= c <= \'Z\') c -= dist; string[i] = c; } while (--i != 0); } } |