Category talk:Wren-str: Difference between revisions
Content added Content deleted
(Bug fix) |
(Bug fixed properly now!) |
||
Line 800: | Line 800: | ||
// Converts a UTF-8 string to upper case. |
// Converts a UTF-8 string to upper case. |
||
⚫ | |||
static upper(s) { |
static upper(s) { |
||
if (!(s is String)) s = "%(s)" |
if (!(s is String)) s = "%(s)" |
||
Line 825: | Line 824: | ||
c == 0x01A1 || c == 0x01B0 || c == 0x01F5) { |
c == 0x01A1 || c == 0x01B0 || c == 0x01F5) { |
||
chars[i] = String.fromCodePoint(c - 1) |
chars[i] = String.fromCodePoint(c - 1) |
||
} else if |
} else if (c == 0x01C5 || c == 0x01C8 || c == 0x01CB || c == 0x01F2) { |
||
⚫ | |||
⚫ | |||
chars[i] = String.fromCodePoint(c - 1) |
chars[i] = String.fromCodePoint(c - 1) |
||
} else if (c == 0x01C6 || c == 0x01C9 || c == 0x01CC || c == 0x01F3) { |
} else if (c == 0x01C6 || c == 0x01C9 || c == 0x01CC || c == 0x01F3) { |
||
chars[i] = String.fromCodePoint( |
chars[i] = String.fromCodePoint(c - 2) |
||
} else if ((c >= 0x01DF && c <= 0x01EF) && (c % 2 == 1)) { |
} else if ((c >= 0x01DF && c <= 0x01EF) && (c % 2 == 1)) { |
||
chars[i] = String.fromCodePoint(c - 1) |
chars[i] = String.fromCodePoint(c - 1) |
||
Line 876: | Line 873: | ||
// Capitalizes the first character of a UTF-8 string. |
// Capitalizes the first character of a UTF-8 string. |
||
⚫ | |||
static capitalize(s) { |
static capitalize(s) { |
||
if (!(s is String)) s = "%(s)" |
if (!(s is String)) s = "%(s)" |
||
Line 881: | Line 879: | ||
var start = (s.startsWith("[") && s.count > 1) ? 1 : 0 |
var start = (s.startsWith("[") && s.count > 1) ? 1 : 0 |
||
var cs = upper(s[start]) |
var cs = upper(s[start]) |
||
var c = cs.codePoints[0] |
|||
⚫ | |||
⚫ | |||
} |
|||
if (s.count > start + 1) cs = cs + s[start+1..-1] |
if (s.count > start + 1) cs = cs + s[start+1..-1] |
||
if (start == 1) cs = "[" + cs |
if (start == 1) cs = "[" + cs |
||
Line 887: | Line 889: | ||
// Capitalizes the first character of each word of a UTF-8 string. |
// Capitalizes the first character of each word of a UTF-8 string. |
||
// Uses title rather than upper case variant if it's one of 4 supported digraphs. |
|||
static title(s) { |
static title(s) { |
||
if (!(s is String)) s = "%(s)" |
if (!(s is String)) s = "%(s)" |