1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 functions operating on Unicode characters and UTF-8 strings.
7 <!-- ##### SECTION Long_Description ##### -->
9 This section describes a number of functions for dealing with
10 Unicode characters and strings. There are analogues of the
11 traditional <filename>ctype.h</filename> character classification
12 and case conversion functions, UTF-8 analogues of some string utility
13 functions, functions to perform normalization, case conversion and
14 collation on UTF-8 strings and finally functions to convert between
15 the UTF-8, UTF-16 and UCS-4 encodings of Unicode.
18 <!-- ##### SECTION See_Also ##### -->
23 <term>g_locale_to_utf8(), g_locale_from_utf8()</term>
25 Convenience functions for converting between UTF-8 and the locale encoding.
32 <!-- ##### SECTION Stability_Level ##### -->
35 <!-- ##### TYPEDEF gunichar ##### -->
37 A type which can hold any UCS-4 character code.
41 <!-- ##### TYPEDEF gunichar2 ##### -->
43 A type which can hold any UTF-16 code
44 point<footnote id="utf16_surrogate_pairs">UTF-16 also has so called
45 <firstterm>surrogate pairs</firstterm> to encode characters beyond the
46 BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored in a
47 single gunichar2 field, but all GLib functions accepting gunichar2 arrays
48 will correctly interpret surrogate pairs.</footnote>.
52 <!-- ##### FUNCTION g_unichar_validate ##### -->
61 <!-- ##### FUNCTION g_unichar_isalnum ##### -->
70 <!-- ##### FUNCTION g_unichar_isalpha ##### -->
79 <!-- ##### FUNCTION g_unichar_iscntrl ##### -->
88 <!-- ##### FUNCTION g_unichar_isdigit ##### -->
97 <!-- ##### FUNCTION g_unichar_isgraph ##### -->
106 <!-- ##### FUNCTION g_unichar_islower ##### -->
115 <!-- ##### FUNCTION g_unichar_isprint ##### -->
124 <!-- ##### FUNCTION g_unichar_ispunct ##### -->
133 <!-- ##### FUNCTION g_unichar_isspace ##### -->
142 <!-- ##### FUNCTION g_unichar_isupper ##### -->
151 <!-- ##### FUNCTION g_unichar_isxdigit ##### -->
160 <!-- ##### FUNCTION g_unichar_istitle ##### -->
169 <!-- ##### FUNCTION g_unichar_isdefined ##### -->
178 <!-- ##### FUNCTION g_unichar_iswide ##### -->
187 <!-- ##### FUNCTION g_unichar_toupper ##### -->
196 <!-- ##### FUNCTION g_unichar_tolower ##### -->
205 <!-- ##### FUNCTION g_unichar_totitle ##### -->
214 <!-- ##### FUNCTION g_unichar_digit_value ##### -->
223 <!-- ##### FUNCTION g_unichar_xdigit_value ##### -->
232 <!-- ##### ENUM GUnicodeType ##### -->
234 These are the possible character classifications.
235 See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html"
236 >http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
241 @G_UNICODE_UNASSIGNED:
242 @G_UNICODE_PRIVATE_USE:
243 @G_UNICODE_SURROGATE:
244 @G_UNICODE_LOWERCASE_LETTER:
245 @G_UNICODE_MODIFIER_LETTER:
246 @G_UNICODE_OTHER_LETTER:
247 @G_UNICODE_TITLECASE_LETTER:
248 @G_UNICODE_UPPERCASE_LETTER:
249 @G_UNICODE_COMBINING_MARK:
250 @G_UNICODE_ENCLOSING_MARK:
251 @G_UNICODE_NON_SPACING_MARK:
252 @G_UNICODE_DECIMAL_NUMBER:
253 @G_UNICODE_LETTER_NUMBER:
254 @G_UNICODE_OTHER_NUMBER:
255 @G_UNICODE_CONNECT_PUNCTUATION:
256 @G_UNICODE_DASH_PUNCTUATION:
257 @G_UNICODE_CLOSE_PUNCTUATION:
258 @G_UNICODE_FINAL_PUNCTUATION:
259 @G_UNICODE_INITIAL_PUNCTUATION:
260 @G_UNICODE_OTHER_PUNCTUATION:
261 @G_UNICODE_OPEN_PUNCTUATION:
262 @G_UNICODE_CURRENCY_SYMBOL:
263 @G_UNICODE_MODIFIER_SYMBOL:
264 @G_UNICODE_MATH_SYMBOL:
265 @G_UNICODE_OTHER_SYMBOL:
266 @G_UNICODE_LINE_SEPARATOR:
267 @G_UNICODE_PARAGRAPH_SEPARATOR:
268 @G_UNICODE_SPACE_SEPARATOR:
270 <!-- ##### FUNCTION g_unichar_type ##### -->
279 <!-- ##### ENUM GUnicodeBreakType ##### -->
281 These are the possible line break classifications.
282 GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1.
283 The five Hangul types were added in Unicode 4.1, so, has been
284 introduced in GLib 2.10. Note that new types may be added in the future.
285 Applications should be ready to handle unknown values.
286 They may be regarded as %G_UNICODE_BREAK_UNKNOWN
287 See <ulink url="http://www.unicode.org/unicode/reports/tr14/"
288 >http://www.unicode.org/unicode/reports/tr14/</ulink>.
292 @G_UNICODE_BREAK_MANDATORY:
293 @G_UNICODE_BREAK_CARRIAGE_RETURN:
294 @G_UNICODE_BREAK_LINE_FEED:
295 @G_UNICODE_BREAK_COMBINING_MARK:
296 @G_UNICODE_BREAK_SURROGATE:
297 @G_UNICODE_BREAK_ZERO_WIDTH_SPACE:
298 @G_UNICODE_BREAK_INSEPARABLE:
299 @G_UNICODE_BREAK_NON_BREAKING_GLUE:
300 @G_UNICODE_BREAK_CONTINGENT:
301 @G_UNICODE_BREAK_SPACE:
302 @G_UNICODE_BREAK_AFTER:
303 @G_UNICODE_BREAK_BEFORE:
304 @G_UNICODE_BREAK_BEFORE_AND_AFTER:
305 @G_UNICODE_BREAK_HYPHEN:
306 @G_UNICODE_BREAK_NON_STARTER:
307 @G_UNICODE_BREAK_OPEN_PUNCTUATION:
308 @G_UNICODE_BREAK_CLOSE_PUNCTUATION:
309 @G_UNICODE_BREAK_QUOTATION:
310 @G_UNICODE_BREAK_EXCLAMATION:
311 @G_UNICODE_BREAK_IDEOGRAPHIC:
312 @G_UNICODE_BREAK_NUMERIC:
313 @G_UNICODE_BREAK_INFIX_SEPARATOR:
314 @G_UNICODE_BREAK_SYMBOL:
315 @G_UNICODE_BREAK_ALPHABETIC:
316 @G_UNICODE_BREAK_PREFIX:
317 @G_UNICODE_BREAK_POSTFIX:
318 @G_UNICODE_BREAK_COMPLEX_CONTEXT:
319 @G_UNICODE_BREAK_AMBIGUOUS:
320 @G_UNICODE_BREAK_UNKNOWN:
321 @G_UNICODE_BREAK_NEXT_LINE:
322 @G_UNICODE_BREAK_WORD_JOINER:
323 @G_UNICODE_BREAK_HANGUL_L_JAMO:
324 @G_UNICODE_BREAK_HANGUL_V_JAMO:
325 @G_UNICODE_BREAK_HANGUL_T_JAMO:
326 @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE:
327 @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE:
329 <!-- ##### FUNCTION g_unichar_break_type ##### -->
338 <!-- ##### FUNCTION g_unicode_canonical_ordering ##### -->
347 <!-- ##### FUNCTION g_unicode_canonical_decomposition ##### -->
357 <!-- ##### FUNCTION g_unichar_get_mirror_char ##### -->
367 <!-- ##### MACRO g_utf8_next_char ##### -->
369 Skips to the next character in a UTF-8 string. The string must be
370 valid; this macro is as fast as possible, and has no error-checking.
371 You would use this macro to iterate over a string character by
372 character. The macro returns the start of the next UTF-8 character.
373 Before using this macro, use g_utf8_validate() to validate strings
374 that may contain invalid UTF-8.
377 @p: Pointer to the start of a valid UTF-8 character.
380 <!-- ##### FUNCTION g_utf8_get_char ##### -->
389 <!-- ##### FUNCTION g_utf8_get_char_validated ##### -->
399 <!-- ##### FUNCTION g_utf8_offset_to_pointer ##### -->
409 <!-- ##### FUNCTION g_utf8_pointer_to_offset ##### -->
419 <!-- ##### FUNCTION g_utf8_prev_char ##### -->
428 <!-- ##### FUNCTION g_utf8_find_next_char ##### -->
436 <!-- # Unused Parameters # -->
440 <!-- ##### FUNCTION g_utf8_find_prev_char ##### -->
450 <!-- ##### FUNCTION g_utf8_strlen ##### -->
460 <!-- ##### FUNCTION g_utf8_strncpy ##### -->
471 <!-- ##### FUNCTION g_utf8_strchr ##### -->
480 <!-- # Unused Parameters # -->
484 <!-- ##### FUNCTION g_utf8_strrchr ##### -->
493 <!-- # Unused Parameters # -->
497 <!-- ##### FUNCTION g_utf8_strreverse ##### -->
507 <!-- ##### FUNCTION g_utf8_validate ##### -->
518 <!-- ##### FUNCTION g_utf8_strup ##### -->
528 <!-- ##### FUNCTION g_utf8_strdown ##### -->
538 <!-- ##### FUNCTION g_utf8_casefold ##### -->
548 <!-- ##### FUNCTION g_utf8_normalize ##### -->
559 <!-- ##### ENUM GNormalizeMode ##### -->
561 Defines how a Unicode string is transformed in a canonical
562 form, standardizing such issues as whether a character with an accent is
563 represented as a base character and combining accent or as a single precomposed
564 character. Unicode strings should generally be normalized before comparing them.
567 @G_NORMALIZE_DEFAULT: standardize differences that do not affect the
568 text content, such as the above-mentioned accent representation.
569 @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT.
570 @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with composed
571 forms rather than a maximally decomposed form.
572 @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE.
573 @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the
574 "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to the
575 standard forms (in this case DIGIT THREE). Formatting information may be
576 lost but for most text operations such characters should be considered the
578 @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL.
579 @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed
580 forms rather than a maximally decomposed form.
581 @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE.
583 <!-- ##### FUNCTION g_utf8_collate ##### -->
593 <!-- ##### FUNCTION g_utf8_collate_key ##### -->
603 <!-- ##### FUNCTION g_utf8_collate_key_for_filename ##### -->
613 <!-- ##### FUNCTION g_utf8_to_utf16 ##### -->
626 <!-- ##### FUNCTION g_utf8_to_ucs4 ##### -->
639 <!-- ##### FUNCTION g_utf8_to_ucs4_fast ##### -->
650 <!-- ##### FUNCTION g_utf16_to_ucs4 ##### -->
663 <!-- ##### FUNCTION g_utf16_to_utf8 ##### -->
676 <!-- ##### FUNCTION g_ucs4_to_utf16 ##### -->
689 <!-- ##### FUNCTION g_ucs4_to_utf8 ##### -->
702 <!-- ##### FUNCTION g_unichar_to_utf8 ##### -->