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.
19 The implementations of the Unicode functions in GLib are based
20 on the Unicode Character Data tables, which are available from
21 <ulink url="http://www.unicode.org">www.unicode.org</ulink>.
22 GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1,
23 GLib 2.12 supports Unicode 5.0.
26 <!-- ##### SECTION See_Also ##### -->
31 <term>g_locale_to_utf8(), g_locale_from_utf8()</term>
33 Convenience functions for converting between UTF-8 and the locale encoding.
40 <!-- ##### SECTION Stability_Level ##### -->
43 <!-- ##### TYPEDEF gunichar ##### -->
45 A type which can hold any UCS-4 character code.
49 <!-- ##### TYPEDEF gunichar2 ##### -->
51 A type which can hold any UTF-16 code
52 point<footnote id="utf16_surrogate_pairs">UTF-16 also has so called
53 <firstterm>surrogate pairs</firstterm> to encode characters beyond the
54 BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored in a
55 single gunichar2 field, but all GLib functions accepting gunichar2 arrays
56 will correctly interpret surrogate pairs.</footnote>.
60 <!-- ##### FUNCTION g_unichar_validate ##### -->
69 <!-- ##### FUNCTION g_unichar_isalnum ##### -->
78 <!-- ##### FUNCTION g_unichar_isalpha ##### -->
87 <!-- ##### FUNCTION g_unichar_iscntrl ##### -->
96 <!-- ##### FUNCTION g_unichar_isdigit ##### -->
105 <!-- ##### FUNCTION g_unichar_isgraph ##### -->
114 <!-- ##### FUNCTION g_unichar_islower ##### -->
123 <!-- ##### FUNCTION g_unichar_isprint ##### -->
132 <!-- ##### FUNCTION g_unichar_ispunct ##### -->
141 <!-- ##### FUNCTION g_unichar_isspace ##### -->
150 <!-- ##### FUNCTION g_unichar_isupper ##### -->
159 <!-- ##### FUNCTION g_unichar_isxdigit ##### -->
168 <!-- ##### FUNCTION g_unichar_istitle ##### -->
177 <!-- ##### FUNCTION g_unichar_isdefined ##### -->
186 <!-- ##### FUNCTION g_unichar_iswide ##### -->
195 <!-- ##### FUNCTION g_unichar_toupper ##### -->
204 <!-- ##### FUNCTION g_unichar_tolower ##### -->
213 <!-- ##### FUNCTION g_unichar_totitle ##### -->
222 <!-- ##### FUNCTION g_unichar_digit_value ##### -->
231 <!-- ##### FUNCTION g_unichar_xdigit_value ##### -->
240 <!-- ##### ENUM GUnicodeType ##### -->
242 These are the possible character classifications.
243 See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html"
244 >http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
249 @G_UNICODE_UNASSIGNED:
250 @G_UNICODE_PRIVATE_USE:
251 @G_UNICODE_SURROGATE:
252 @G_UNICODE_LOWERCASE_LETTER:
253 @G_UNICODE_MODIFIER_LETTER:
254 @G_UNICODE_OTHER_LETTER:
255 @G_UNICODE_TITLECASE_LETTER:
256 @G_UNICODE_UPPERCASE_LETTER:
257 @G_UNICODE_COMBINING_MARK:
258 @G_UNICODE_ENCLOSING_MARK:
259 @G_UNICODE_NON_SPACING_MARK:
260 @G_UNICODE_DECIMAL_NUMBER:
261 @G_UNICODE_LETTER_NUMBER:
262 @G_UNICODE_OTHER_NUMBER:
263 @G_UNICODE_CONNECT_PUNCTUATION:
264 @G_UNICODE_DASH_PUNCTUATION:
265 @G_UNICODE_CLOSE_PUNCTUATION:
266 @G_UNICODE_FINAL_PUNCTUATION:
267 @G_UNICODE_INITIAL_PUNCTUATION:
268 @G_UNICODE_OTHER_PUNCTUATION:
269 @G_UNICODE_OPEN_PUNCTUATION:
270 @G_UNICODE_CURRENCY_SYMBOL:
271 @G_UNICODE_MODIFIER_SYMBOL:
272 @G_UNICODE_MATH_SYMBOL:
273 @G_UNICODE_OTHER_SYMBOL:
274 @G_UNICODE_LINE_SEPARATOR:
275 @G_UNICODE_PARAGRAPH_SEPARATOR:
276 @G_UNICODE_SPACE_SEPARATOR:
278 <!-- ##### FUNCTION g_unichar_type ##### -->
287 <!-- ##### ENUM GUnicodeBreakType ##### -->
289 These are the possible line break classifications.
290 The five Hangul types were added in Unicode 4.1, so, has been
291 introduced in GLib 2.10. Note that new types may be added in the future.
292 Applications should be ready to handle unknown values.
293 They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
294 See <ulink url="http://www.unicode.org/unicode/reports/tr14/"
295 >http://www.unicode.org/unicode/reports/tr14/</ulink>.
299 @G_UNICODE_BREAK_MANDATORY:
300 @G_UNICODE_BREAK_CARRIAGE_RETURN:
301 @G_UNICODE_BREAK_LINE_FEED:
302 @G_UNICODE_BREAK_COMBINING_MARK:
303 @G_UNICODE_BREAK_SURROGATE:
304 @G_UNICODE_BREAK_ZERO_WIDTH_SPACE:
305 @G_UNICODE_BREAK_INSEPARABLE:
306 @G_UNICODE_BREAK_NON_BREAKING_GLUE:
307 @G_UNICODE_BREAK_CONTINGENT:
308 @G_UNICODE_BREAK_SPACE:
309 @G_UNICODE_BREAK_AFTER:
310 @G_UNICODE_BREAK_BEFORE:
311 @G_UNICODE_BREAK_BEFORE_AND_AFTER:
312 @G_UNICODE_BREAK_HYPHEN:
313 @G_UNICODE_BREAK_NON_STARTER:
314 @G_UNICODE_BREAK_OPEN_PUNCTUATION:
315 @G_UNICODE_BREAK_CLOSE_PUNCTUATION:
316 @G_UNICODE_BREAK_QUOTATION:
317 @G_UNICODE_BREAK_EXCLAMATION:
318 @G_UNICODE_BREAK_IDEOGRAPHIC:
319 @G_UNICODE_BREAK_NUMERIC:
320 @G_UNICODE_BREAK_INFIX_SEPARATOR:
321 @G_UNICODE_BREAK_SYMBOL:
322 @G_UNICODE_BREAK_ALPHABETIC:
323 @G_UNICODE_BREAK_PREFIX:
324 @G_UNICODE_BREAK_POSTFIX:
325 @G_UNICODE_BREAK_COMPLEX_CONTEXT:
326 @G_UNICODE_BREAK_AMBIGUOUS:
327 @G_UNICODE_BREAK_UNKNOWN:
328 @G_UNICODE_BREAK_NEXT_LINE:
329 @G_UNICODE_BREAK_WORD_JOINER:
330 @G_UNICODE_BREAK_HANGUL_L_JAMO:
331 @G_UNICODE_BREAK_HANGUL_V_JAMO:
332 @G_UNICODE_BREAK_HANGUL_T_JAMO:
333 @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE:
334 @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE:
336 <!-- ##### FUNCTION g_unichar_break_type ##### -->
345 <!-- ##### FUNCTION g_unicode_canonical_ordering ##### -->
354 <!-- ##### FUNCTION g_unicode_canonical_decomposition ##### -->
364 <!-- ##### FUNCTION g_unichar_get_mirror_char ##### -->
374 <!-- ##### MACRO g_utf8_next_char ##### -->
376 Skips to the next character in a UTF-8 string. The string must be
377 valid; this macro is as fast as possible, and has no error-checking.
378 You would use this macro to iterate over a string character by
379 character. The macro returns the start of the next UTF-8 character.
380 Before using this macro, use g_utf8_validate() to validate strings
381 that may contain invalid UTF-8.
384 @p: Pointer to the start of a valid UTF-8 character.
387 <!-- ##### FUNCTION g_utf8_get_char ##### -->
396 <!-- ##### FUNCTION g_utf8_get_char_validated ##### -->
406 <!-- ##### FUNCTION g_utf8_offset_to_pointer ##### -->
416 <!-- ##### FUNCTION g_utf8_pointer_to_offset ##### -->
426 <!-- ##### FUNCTION g_utf8_prev_char ##### -->
435 <!-- ##### FUNCTION g_utf8_find_next_char ##### -->
443 <!-- # Unused Parameters # -->
447 <!-- ##### FUNCTION g_utf8_find_prev_char ##### -->
457 <!-- ##### FUNCTION g_utf8_strlen ##### -->
467 <!-- ##### FUNCTION g_utf8_strncpy ##### -->
478 <!-- ##### FUNCTION g_utf8_strchr ##### -->
487 <!-- # Unused Parameters # -->
491 <!-- ##### FUNCTION g_utf8_strrchr ##### -->
500 <!-- # Unused Parameters # -->
504 <!-- ##### FUNCTION g_utf8_strreverse ##### -->
514 <!-- ##### FUNCTION g_utf8_validate ##### -->
525 <!-- ##### FUNCTION g_utf8_strup ##### -->
535 <!-- ##### FUNCTION g_utf8_strdown ##### -->
545 <!-- ##### FUNCTION g_utf8_casefold ##### -->
555 <!-- ##### FUNCTION g_utf8_normalize ##### -->
566 <!-- ##### ENUM GNormalizeMode ##### -->
568 Defines how a Unicode string is transformed in a canonical
569 form, standardizing such issues as whether a character with an accent is
570 represented as a base character and combining accent or as a single precomposed
571 character. Unicode strings should generally be normalized before comparing them.
574 @G_NORMALIZE_DEFAULT: standardize differences that do not affect the
575 text content, such as the above-mentioned accent representation.
576 @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT.
577 @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with composed
578 forms rather than a maximally decomposed form.
579 @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE.
580 @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the
581 "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to the
582 standard forms (in this case DIGIT THREE). Formatting information may be
583 lost but for most text operations such characters should be considered the
585 @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL.
586 @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed
587 forms rather than a maximally decomposed form.
588 @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE.
590 <!-- ##### FUNCTION g_utf8_collate ##### -->
600 <!-- ##### FUNCTION g_utf8_collate_key ##### -->
610 <!-- ##### FUNCTION g_utf8_collate_key_for_filename ##### -->
620 <!-- ##### FUNCTION g_utf8_to_utf16 ##### -->
633 <!-- ##### FUNCTION g_utf8_to_ucs4 ##### -->
646 <!-- ##### FUNCTION g_utf8_to_ucs4_fast ##### -->
657 <!-- ##### FUNCTION g_utf16_to_ucs4 ##### -->
670 <!-- ##### FUNCTION g_utf16_to_utf8 ##### -->
683 <!-- ##### FUNCTION g_ucs4_to_utf16 ##### -->
696 <!-- ##### FUNCTION g_ucs4_to_utf8 ##### -->
709 <!-- ##### FUNCTION g_unichar_to_utf8 ##### -->