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_iswide_cjk ##### -->
204 <!-- ##### FUNCTION g_unichar_toupper ##### -->
213 <!-- ##### FUNCTION g_unichar_tolower ##### -->
222 <!-- ##### FUNCTION g_unichar_totitle ##### -->
231 <!-- ##### FUNCTION g_unichar_digit_value ##### -->
240 <!-- ##### FUNCTION g_unichar_xdigit_value ##### -->
249 <!-- ##### ENUM GUnicodeType ##### -->
251 These are the possible character classifications.
252 See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html"
253 >http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
258 @G_UNICODE_UNASSIGNED:
259 @G_UNICODE_PRIVATE_USE:
260 @G_UNICODE_SURROGATE:
261 @G_UNICODE_LOWERCASE_LETTER:
262 @G_UNICODE_MODIFIER_LETTER:
263 @G_UNICODE_OTHER_LETTER:
264 @G_UNICODE_TITLECASE_LETTER:
265 @G_UNICODE_UPPERCASE_LETTER:
266 @G_UNICODE_COMBINING_MARK:
267 @G_UNICODE_ENCLOSING_MARK:
268 @G_UNICODE_NON_SPACING_MARK:
269 @G_UNICODE_DECIMAL_NUMBER:
270 @G_UNICODE_LETTER_NUMBER:
271 @G_UNICODE_OTHER_NUMBER:
272 @G_UNICODE_CONNECT_PUNCTUATION:
273 @G_UNICODE_DASH_PUNCTUATION:
274 @G_UNICODE_CLOSE_PUNCTUATION:
275 @G_UNICODE_FINAL_PUNCTUATION:
276 @G_UNICODE_INITIAL_PUNCTUATION:
277 @G_UNICODE_OTHER_PUNCTUATION:
278 @G_UNICODE_OPEN_PUNCTUATION:
279 @G_UNICODE_CURRENCY_SYMBOL:
280 @G_UNICODE_MODIFIER_SYMBOL:
281 @G_UNICODE_MATH_SYMBOL:
282 @G_UNICODE_OTHER_SYMBOL:
283 @G_UNICODE_LINE_SEPARATOR:
284 @G_UNICODE_PARAGRAPH_SEPARATOR:
285 @G_UNICODE_SPACE_SEPARATOR:
287 <!-- ##### FUNCTION g_unichar_type ##### -->
296 <!-- ##### ENUM GUnicodeBreakType ##### -->
298 These are the possible line break classifications.
299 The five Hangul types were added in Unicode 4.1, so, has been
300 introduced in GLib 2.10. Note that new types may be added in the future.
301 Applications should be ready to handle unknown values.
302 They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
303 See <ulink url="http://www.unicode.org/unicode/reports/tr14/"
304 >http://www.unicode.org/unicode/reports/tr14/</ulink>.
307 @G_UNICODE_BREAK_MANDATORY:
308 @G_UNICODE_BREAK_CARRIAGE_RETURN:
309 @G_UNICODE_BREAK_LINE_FEED:
310 @G_UNICODE_BREAK_COMBINING_MARK:
311 @G_UNICODE_BREAK_SURROGATE:
312 @G_UNICODE_BREAK_ZERO_WIDTH_SPACE:
313 @G_UNICODE_BREAK_INSEPARABLE:
314 @G_UNICODE_BREAK_NON_BREAKING_GLUE:
315 @G_UNICODE_BREAK_CONTINGENT:
316 @G_UNICODE_BREAK_SPACE:
317 @G_UNICODE_BREAK_AFTER:
318 @G_UNICODE_BREAK_BEFORE:
319 @G_UNICODE_BREAK_BEFORE_AND_AFTER:
320 @G_UNICODE_BREAK_HYPHEN:
321 @G_UNICODE_BREAK_NON_STARTER:
322 @G_UNICODE_BREAK_OPEN_PUNCTUATION:
323 @G_UNICODE_BREAK_CLOSE_PUNCTUATION:
324 @G_UNICODE_BREAK_QUOTATION:
325 @G_UNICODE_BREAK_EXCLAMATION:
326 @G_UNICODE_BREAK_IDEOGRAPHIC:
327 @G_UNICODE_BREAK_NUMERIC:
328 @G_UNICODE_BREAK_INFIX_SEPARATOR:
329 @G_UNICODE_BREAK_SYMBOL:
330 @G_UNICODE_BREAK_ALPHABETIC:
331 @G_UNICODE_BREAK_PREFIX:
332 @G_UNICODE_BREAK_POSTFIX:
333 @G_UNICODE_BREAK_COMPLEX_CONTEXT:
334 @G_UNICODE_BREAK_AMBIGUOUS:
335 @G_UNICODE_BREAK_UNKNOWN:
336 @G_UNICODE_BREAK_NEXT_LINE:
337 @G_UNICODE_BREAK_WORD_JOINER:
338 @G_UNICODE_BREAK_HANGUL_L_JAMO:
339 @G_UNICODE_BREAK_HANGUL_V_JAMO:
340 @G_UNICODE_BREAK_HANGUL_T_JAMO:
341 @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE:
342 @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE:
344 <!-- ##### FUNCTION g_unichar_break_type ##### -->
353 <!-- ##### FUNCTION g_unicode_canonical_ordering ##### -->
362 <!-- ##### FUNCTION g_unicode_canonical_decomposition ##### -->
372 <!-- ##### FUNCTION g_unichar_get_mirror_char ##### -->
382 <!-- ##### ENUM GUnicodeScript ##### -->
384 The #GUnicodeScript enumeration identifies different writing
385 systems. The values correspond to the names as defined in the
386 Unicode standard. The enumeration has been added in GLib 2.14.
387 Note that new types may be added in the future. Applications
388 should be ready to handle unknown values.
390 url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
391 #24: Script names</ulink>.
394 @G_UNICODE_SCRIPT_INVALID_CODE: a value never returned from g_unichar_get_script()
395 @G_UNICODE_SCRIPT_COMMON: a character used by multiple different scripts
396 @G_UNICODE_SCRIPT_INHERITED: a mark glyph that takes its script from the
397 base glyph to which it is attached
398 @G_UNICODE_SCRIPT_ARABIC: Arabic
399 @G_UNICODE_SCRIPT_ARMENIAN: Armenian
400 @G_UNICODE_SCRIPT_BENGALI: Bengali
401 @G_UNICODE_SCRIPT_BOPOMOFO: Bopomofo
402 @G_UNICODE_SCRIPT_CHEROKEE: Cherokee
403 @G_UNICODE_SCRIPT_COPTIC: Coptic
404 @G_UNICODE_SCRIPT_CYRILLIC: Cyrillic
405 @G_UNICODE_SCRIPT_DESERET: Deseret
406 @G_UNICODE_SCRIPT_DEVANAGARI: Devanagari
407 @G_UNICODE_SCRIPT_ETHIOPIC: Ethiopic
408 @G_UNICODE_SCRIPT_GEORGIAN: Georgian
409 @G_UNICODE_SCRIPT_GOTHIC: Gothic
410 @G_UNICODE_SCRIPT_GREEK: Greek
411 @G_UNICODE_SCRIPT_GUJARATI: Gujarati
412 @G_UNICODE_SCRIPT_GURMUKHI: Gurmukhi
413 @G_UNICODE_SCRIPT_HAN: Han
414 @G_UNICODE_SCRIPT_HANGUL: Hangul
415 @G_UNICODE_SCRIPT_HEBREW: Hebrew
416 @G_UNICODE_SCRIPT_HIRAGANA: Hiragana
417 @G_UNICODE_SCRIPT_KANNADA: Kannada
418 @G_UNICODE_SCRIPT_KATAKANA: Katakana
419 @G_UNICODE_SCRIPT_KHMER: Khmer
420 @G_UNICODE_SCRIPT_LAO: Lao
421 @G_UNICODE_SCRIPT_LATIN: Latin
422 @G_UNICODE_SCRIPT_MALAYALAM: Malayalam
423 @G_UNICODE_SCRIPT_MONGOLIAN: Mongolian
424 @G_UNICODE_SCRIPT_MYANMAR: Myanmar
425 @G_UNICODE_SCRIPT_OGHAM: Ogham
426 @G_UNICODE_SCRIPT_OLD_ITALIC: Old Italic
427 @G_UNICODE_SCRIPT_ORIYA: Oriya
428 @G_UNICODE_SCRIPT_RUNIC: Runic
429 @G_UNICODE_SCRIPT_SINHALA: Sinhala
430 @G_UNICODE_SCRIPT_SYRIAC: Syriac
431 @G_UNICODE_SCRIPT_TAMIL: Tamil
432 @G_UNICODE_SCRIPT_TELUGU: Telugu
433 @G_UNICODE_SCRIPT_THAANA: Thaana
434 @G_UNICODE_SCRIPT_THAI: Thai
435 @G_UNICODE_SCRIPT_TIBETAN: Tibetan
436 @G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL:
438 @G_UNICODE_SCRIPT_YI: Yi
439 @G_UNICODE_SCRIPT_TAGALOG: Tagalog
440 @G_UNICODE_SCRIPT_HANUNOO: Hanunoo
441 @G_UNICODE_SCRIPT_BUHID: Buhid
442 @G_UNICODE_SCRIPT_TAGBANWA: Tagbanwa
443 @G_UNICODE_SCRIPT_BRAILLE: Braille
444 @G_UNICODE_SCRIPT_CYPRIOT: Cypriot
445 @G_UNICODE_SCRIPT_LIMBU: Limbu
446 @G_UNICODE_SCRIPT_OSMANYA: Osmanya
447 @G_UNICODE_SCRIPT_SHAVIAN: Shavian
448 @G_UNICODE_SCRIPT_LINEAR_B: Linear B
449 @G_UNICODE_SCRIPT_TAI_LE: Tai Le
450 @G_UNICODE_SCRIPT_UGARITIC: Ugaritic
451 @G_UNICODE_SCRIPT_NEW_TAI_LUE: New Tai Lue
452 @G_UNICODE_SCRIPT_BUGINESE: Buginese
453 @G_UNICODE_SCRIPT_GLAGOLITIC: Glagolitic
454 @G_UNICODE_SCRIPT_TIFINAGH: Tifinagh
455 @G_UNICODE_SCRIPT_SYLOTI_NAGRI: Syloti Nagri
456 @G_UNICODE_SCRIPT_OLD_PERSIAN: Old Persian
457 @G_UNICODE_SCRIPT_KHAROSHTHI: Kharoshthi
458 @G_UNICODE_SCRIPT_UNKNOWN: an unassigned code point
459 @G_UNICODE_SCRIPT_BALINESE: Balinese
460 @G_UNICODE_SCRIPT_CUNEIFORM: Cuneiform
461 @G_UNICODE_SCRIPT_PHOENICIAN: Phoenician
462 @G_UNICODE_SCRIPT_PHAGS_PA: Phags-pa
463 @G_UNICODE_SCRIPT_NKO: N'Ko
466 <!-- ##### FUNCTION g_unichar_get_script ##### -->
475 <!-- ##### MACRO g_utf8_next_char ##### -->
477 Skips to the next character in a UTF-8 string. The string must be
478 valid; this macro is as fast as possible, and has no error-checking.
479 You would use this macro to iterate over a string character by
480 character. The macro returns the start of the next UTF-8 character.
481 Before using this macro, use g_utf8_validate() to validate strings
482 that may contain invalid UTF-8.
485 @p: Pointer to the start of a valid UTF-8 character.
488 <!-- ##### FUNCTION g_utf8_get_char ##### -->
497 <!-- ##### FUNCTION g_utf8_get_char_validated ##### -->
507 <!-- ##### FUNCTION g_utf8_offset_to_pointer ##### -->
517 <!-- ##### FUNCTION g_utf8_pointer_to_offset ##### -->
527 <!-- ##### FUNCTION g_utf8_prev_char ##### -->
536 <!-- ##### FUNCTION g_utf8_find_next_char ##### -->
546 <!-- ##### FUNCTION g_utf8_find_prev_char ##### -->
556 <!-- ##### FUNCTION g_utf8_strlen ##### -->
566 <!-- ##### FUNCTION g_utf8_strncpy ##### -->
577 <!-- ##### FUNCTION g_utf8_strchr ##### -->
588 <!-- ##### FUNCTION g_utf8_strrchr ##### -->
599 <!-- ##### FUNCTION g_utf8_strreverse ##### -->
609 <!-- ##### FUNCTION g_utf8_validate ##### -->
620 <!-- ##### FUNCTION g_utf8_strup ##### -->
630 <!-- ##### FUNCTION g_utf8_strdown ##### -->
640 <!-- ##### FUNCTION g_utf8_casefold ##### -->
650 <!-- ##### FUNCTION g_utf8_normalize ##### -->
661 <!-- ##### ENUM GNormalizeMode ##### -->
663 Defines how a Unicode string is transformed in a canonical
664 form, standardizing such issues as whether a character with an accent is
665 represented as a base character and combining accent or as a single precomposed
666 character. Unicode strings should generally be normalized before comparing them.
669 @G_NORMALIZE_DEFAULT: standardize differences that do not affect the
670 text content, such as the above-mentioned accent representation.
671 @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT.
672 @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with composed
673 forms rather than a maximally decomposed form.
674 @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE.
675 @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the
676 "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to the
677 standard forms (in this case DIGIT THREE). Formatting information may be
678 lost but for most text operations such characters should be considered the
680 @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL.
681 @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed
682 forms rather than a maximally decomposed form.
683 @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE.
685 <!-- ##### FUNCTION g_utf8_collate ##### -->
695 <!-- ##### FUNCTION g_utf8_collate_key ##### -->
705 <!-- ##### FUNCTION g_utf8_collate_key_for_filename ##### -->
715 <!-- ##### FUNCTION g_utf8_to_utf16 ##### -->
728 <!-- ##### FUNCTION g_utf8_to_ucs4 ##### -->
741 <!-- ##### FUNCTION g_utf8_to_ucs4_fast ##### -->
752 <!-- ##### FUNCTION g_utf16_to_ucs4 ##### -->
765 <!-- ##### FUNCTION g_utf16_to_utf8 ##### -->
778 <!-- ##### FUNCTION g_ucs4_to_utf16 ##### -->
791 <!-- ##### FUNCTION g_ucs4_to_utf8 ##### -->
804 <!-- ##### FUNCTION g_unichar_to_utf8 ##### -->