6 * @ch: A Latin-1 character.
8 * If @ch is an uppercase character in the Latin-1 character set, converts it
9 * to lowercase. Otherwise, leaves it unchanged.
11 * Returns: A lowercase or non-letter Latin-1 character.
14 glk_char_to_lower(unsigned char ch)
16 if( (ch >= 0x41 && ch <= 0x5A) || (ch >= 0xC0 && ch <= 0xD6) || (ch >= 0xD8 && ch <= 0xDE) )
23 * @ch: A Latin-1 character.
25 * If @ch is a lowercase character in the Latin-1 character set, converts it to
26 * uppercase. Otherwise, leaves it unchanged.
28 * Returns: An uppercase or non-letter Latin-1 character.
31 glk_char_to_upper(unsigned char ch)
33 if( (ch >= 0x61 && ch <= 0x7A) || (ch >= 0xE0 && ch <= 0xF6) || (ch >= 0xF8 && ch <= 0xFE) )
38 #ifdef GLK_MODULE_UNICODE
41 * glk_buffer_to_lower_case_uni:
42 * @buf: A character array in UCS-4.
43 * @len: Available length of @buf.
44 * @numchars: Number of characters in @buf.
46 * Converts the first @numchars characters of @buf to their lowercase
47 * equivalents, if there is such a thing. These functions provide two length
48 * arguments because a string of Unicode characters may expand when its case
49 * changes. The @len argument is the available length of the buffer; @numchars
50 * is the number of characters in the buffer initially. (So @numchars must be
51 * less than or equal to @len. The contents of the buffer after @numchars do
52 * not affect the operation.)
54 * Returns: The number of characters after conversion. If this is greater than
55 * @len, the characters in the array will be safely truncated at len, but the
56 * true count will be returned. (The contents of the buffer after the returned
57 * count are undefined.)
60 glk_buffer_to_lower_case_uni(glui32 *buf, glui32 len, glui32 numchars)
62 g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
63 g_return_val_if_fail(numchars <= len, 0);
65 /* GLib has a function that converts _one_ UCS-4 character to _one_
66 lowercase UCS-4 character; so apparently we don't have to worry about the
67 string length changing... */
69 for(ptr = buf; ptr < buf + numchars; ptr++)
70 *ptr = g_unichar_tolower(*ptr);
76 * glk_buffer_to_upper_case_uni:
77 * @buf: A character array in UCS-4.
78 * @len: Available length of @buf.
79 * @numchars: Number of characters in @buf.
81 * Converts the first @numchars characters of @buf to their uppercase
82 * equivalents, if there is such a thing. See glk_buffer_to_lower_case_uni().
84 * Returns: The number of characters after conversion.
87 glk_buffer_to_upper_case_uni(glui32 *buf, glui32 len, glui32 numchars)
89 g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
90 g_return_val_if_fail(numchars <= len, 0);
92 /* GLib has a function that converts _one_ UCS-4 character to _one_
93 uppercase UCS-4 character; so apparently we don't have to worry about the
94 string length changing... */
96 for(ptr = buf; ptr < buf + numchars; ptr++)
97 *ptr = g_unichar_toupper(*ptr);
103 * glk_buffer_to_title_case_uni:
104 * @buf: A character array in UCS-4.
105 * @len: Available length of @buf.
106 * @numchars: Number of characters in @buf.
107 * @lowerrest: #TRUE if the rest of @buf should be lowercased, #FALSE
110 * Converts the first character of @buf to uppercase, if there is such a thing.
111 * See glk_buffer_to_lower_case_uni(). If @lowerrest is #TRUE, then the
112 * remainder of @buf is lowercased.
114 * Returns: The number of characters after conversion.
117 glk_buffer_to_title_case_uni(glui32 *buf, glui32 len, glui32 numchars,
120 g_return_val_if_fail(buf != NULL && (len > 0 || numchars > 0), 0);
121 g_return_val_if_fail(numchars <= len, 0);
123 /* GLib has a function that converts _one_ UCS-4 character to _one_
124 uppercase UCS-4 character; so apparently we don't have to worry about the
125 string length changing... */
126 *buf = g_unichar_totitle(*buf);
127 /* Call lowercase on the rest of the string */
129 return glk_buffer_to_lower_case_uni(buf + 1, len - 1, numchars - 1) +1;
133 #endif /* GLK_MODULE_UNICODE */