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, GLib 2.16.3 supports Unicode 5.1.
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_isdefined ##### -->
105 <!-- ##### FUNCTION g_unichar_isdigit ##### -->
114 <!-- ##### FUNCTION g_unichar_isgraph ##### -->
123 <!-- ##### FUNCTION g_unichar_islower ##### -->
132 <!-- ##### FUNCTION g_unichar_ismark ##### -->
141 <!-- ##### FUNCTION g_unichar_isprint ##### -->
150 <!-- ##### FUNCTION g_unichar_ispunct ##### -->
159 <!-- ##### FUNCTION g_unichar_isspace ##### -->
168 <!-- ##### FUNCTION g_unichar_istitle ##### -->
177 <!-- ##### FUNCTION g_unichar_isupper ##### -->
186 <!-- ##### FUNCTION g_unichar_isxdigit ##### -->
195 <!-- ##### FUNCTION g_unichar_iswide ##### -->
204 <!-- ##### FUNCTION g_unichar_iswide_cjk ##### -->
213 <!-- ##### FUNCTION g_unichar_iszerowidth ##### -->
222 <!-- ##### FUNCTION g_unichar_toupper ##### -->
231 <!-- ##### FUNCTION g_unichar_tolower ##### -->
240 <!-- ##### FUNCTION g_unichar_totitle ##### -->
249 <!-- ##### FUNCTION g_unichar_digit_value ##### -->
258 <!-- ##### FUNCTION g_unichar_xdigit_value ##### -->
267 <!-- ##### ENUM GUnicodeType ##### -->
269 These are the possible character classifications from the
270 Unicode specification.
271 See <ulink url="http://www.unicode.org/Public/UNIDATA/UnicodeData.html"
272 >http://www.unicode.org/Public/UNIDATA/UnicodeData.html</ulink>.
275 @G_UNICODE_CONTROL: General category "Other, Control" (Cc)
276 @G_UNICODE_FORMAT: General category "Other, Format" (Cf)
277 @G_UNICODE_UNASSIGNED: General category "Other, Not Assigned" (Cn)
278 @G_UNICODE_PRIVATE_USE: General category "Other, Private Use" (Co)
279 @G_UNICODE_SURROGATE: General category "Other, Surrogate" (Cs)
280 @G_UNICODE_LOWERCASE_LETTER: General category "Letter, Lowercase" (Ll)
281 @G_UNICODE_MODIFIER_LETTER: General category "Letter, Modifier" (Lm)
282 @G_UNICODE_OTHER_LETTER: General category "Letter, Other" (Lo)
283 @G_UNICODE_TITLECASE_LETTER: General category "Letter, Titlecase" (Lt)
284 @G_UNICODE_UPPERCASE_LETTER: General category "Letter, Uppercase" (Lu)
285 @G_UNICODE_COMBINING_MARK: General category "Mark, Spacing Combining" (Mc)
286 @G_UNICODE_ENCLOSING_MARK: General category "Mark, Enclosing" (Me)
287 @G_UNICODE_NON_SPACING_MARK: General category "Mark, Nonspacing" (Mn)
288 @G_UNICODE_DECIMAL_NUMBER: General category "Number, Decimal Digit" (Nd)
289 @G_UNICODE_LETTER_NUMBER: General category "Number, Letter" (Nl)
290 @G_UNICODE_OTHER_NUMBER: General category "Number, Other" (No)
291 @G_UNICODE_CONNECT_PUNCTUATION: General category "Punctuation, Connector" (Pc)
292 @G_UNICODE_DASH_PUNCTUATION: General category "Punctuation, Dash" (Pd)
293 @G_UNICODE_CLOSE_PUNCTUATION: General category "Punctuation, Close" (Pe)
294 @G_UNICODE_FINAL_PUNCTUATION: General category "Punctuation, Final quote" (Pf)
295 @G_UNICODE_INITIAL_PUNCTUATION: General category "Punctuation, Initial quote" (Pi)
296 @G_UNICODE_OTHER_PUNCTUATION: General category "Punctuation, Other" (Po)
297 @G_UNICODE_OPEN_PUNCTUATION: General category "Punctuation, Open" (Ps)
298 @G_UNICODE_CURRENCY_SYMBOL: General category "Symbol, Currency" (Sc)
299 @G_UNICODE_MODIFIER_SYMBOL: General category "Symbol, Modifier" (Sk)
300 @G_UNICODE_MATH_SYMBOL: General category "Symbol, Math" (Sm)
301 @G_UNICODE_OTHER_SYMBOL: General category "Symbol, Other" (So)
302 @G_UNICODE_LINE_SEPARATOR: General category "Separator, Line" (Zl)
303 @G_UNICODE_PARAGRAPH_SEPARATOR: General category "Separator, Paragraph" (Zp)
304 @G_UNICODE_SPACE_SEPARATOR: General category "Separator, Space" (Zs)
306 <!-- ##### FUNCTION g_unichar_type ##### -->
315 <!-- ##### ENUM GUnicodeBreakType ##### -->
317 These are the possible line break classifications.
318 The five Hangul types were added in Unicode 4.1, so, has been
319 introduced in GLib 2.10. Note that new types may be added in the future.
320 Applications should be ready to handle unknown values.
321 They may be regarded as %G_UNICODE_BREAK_UNKNOWN.
322 See <ulink url="http://www.unicode.org/unicode/reports/tr14/"
323 >http://www.unicode.org/unicode/reports/tr14/</ulink>.
326 @G_UNICODE_BREAK_MANDATORY:
327 @G_UNICODE_BREAK_CARRIAGE_RETURN:
328 @G_UNICODE_BREAK_LINE_FEED:
329 @G_UNICODE_BREAK_COMBINING_MARK:
330 @G_UNICODE_BREAK_SURROGATE:
331 @G_UNICODE_BREAK_ZERO_WIDTH_SPACE:
332 @G_UNICODE_BREAK_INSEPARABLE:
333 @G_UNICODE_BREAK_NON_BREAKING_GLUE:
334 @G_UNICODE_BREAK_CONTINGENT:
335 @G_UNICODE_BREAK_SPACE:
336 @G_UNICODE_BREAK_AFTER:
337 @G_UNICODE_BREAK_BEFORE:
338 @G_UNICODE_BREAK_BEFORE_AND_AFTER:
339 @G_UNICODE_BREAK_HYPHEN:
340 @G_UNICODE_BREAK_NON_STARTER:
341 @G_UNICODE_BREAK_OPEN_PUNCTUATION:
342 @G_UNICODE_BREAK_CLOSE_PUNCTUATION:
343 @G_UNICODE_BREAK_QUOTATION:
344 @G_UNICODE_BREAK_EXCLAMATION:
345 @G_UNICODE_BREAK_IDEOGRAPHIC:
346 @G_UNICODE_BREAK_NUMERIC:
347 @G_UNICODE_BREAK_INFIX_SEPARATOR:
348 @G_UNICODE_BREAK_SYMBOL:
349 @G_UNICODE_BREAK_ALPHABETIC:
350 @G_UNICODE_BREAK_PREFIX:
351 @G_UNICODE_BREAK_POSTFIX:
352 @G_UNICODE_BREAK_COMPLEX_CONTEXT:
353 @G_UNICODE_BREAK_AMBIGUOUS:
354 @G_UNICODE_BREAK_UNKNOWN:
355 @G_UNICODE_BREAK_NEXT_LINE:
356 @G_UNICODE_BREAK_WORD_JOINER:
357 @G_UNICODE_BREAK_HANGUL_L_JAMO:
358 @G_UNICODE_BREAK_HANGUL_V_JAMO:
359 @G_UNICODE_BREAK_HANGUL_T_JAMO:
360 @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE:
361 @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE:
363 <!-- ##### FUNCTION g_unichar_break_type ##### -->
372 <!-- ##### FUNCTION g_unichar_combining_class ##### -->
381 <!-- ##### FUNCTION g_unicode_canonical_ordering ##### -->
390 <!-- ##### FUNCTION g_unicode_canonical_decomposition ##### -->
400 <!-- ##### FUNCTION g_unichar_get_mirror_char ##### -->
410 <!-- ##### ENUM GUnicodeScript ##### -->
412 The #GUnicodeScript enumeration identifies different writing
413 systems. The values correspond to the names as defined in the
414 Unicode standard. The enumeration has been added in GLib 2.14,
415 and is interchangeable with #PangoScript.
416 Note that new types may be added in the future. Applications
417 should be ready to handle unknown values.
419 url="http://www.unicode.org/reports/tr24/">Unicode Standard Annex
420 #24: Script names</ulink>.
423 @G_UNICODE_SCRIPT_INVALID_CODE: a value never returned from g_unichar_get_script()
424 @G_UNICODE_SCRIPT_COMMON: a character used by multiple different scripts
425 @G_UNICODE_SCRIPT_INHERITED: a mark glyph that takes its script from the
426 base glyph to which it is attached
427 @G_UNICODE_SCRIPT_ARABIC: Arabic
428 @G_UNICODE_SCRIPT_ARMENIAN: Armenian
429 @G_UNICODE_SCRIPT_BENGALI: Bengali
430 @G_UNICODE_SCRIPT_BOPOMOFO: Bopomofo
431 @G_UNICODE_SCRIPT_CHEROKEE: Cherokee
432 @G_UNICODE_SCRIPT_COPTIC: Coptic
433 @G_UNICODE_SCRIPT_CYRILLIC: Cyrillic
434 @G_UNICODE_SCRIPT_DESERET: Deseret
435 @G_UNICODE_SCRIPT_DEVANAGARI: Devanagari
436 @G_UNICODE_SCRIPT_ETHIOPIC: Ethiopic
437 @G_UNICODE_SCRIPT_GEORGIAN: Georgian
438 @G_UNICODE_SCRIPT_GOTHIC: Gothic
439 @G_UNICODE_SCRIPT_GREEK: Greek
440 @G_UNICODE_SCRIPT_GUJARATI: Gujarati
441 @G_UNICODE_SCRIPT_GURMUKHI: Gurmukhi
442 @G_UNICODE_SCRIPT_HAN: Han
443 @G_UNICODE_SCRIPT_HANGUL: Hangul
444 @G_UNICODE_SCRIPT_HEBREW: Hebrew
445 @G_UNICODE_SCRIPT_HIRAGANA: Hiragana
446 @G_UNICODE_SCRIPT_KANNADA: Kannada
447 @G_UNICODE_SCRIPT_KATAKANA: Katakana
448 @G_UNICODE_SCRIPT_KHMER: Khmer
449 @G_UNICODE_SCRIPT_LAO: Lao
450 @G_UNICODE_SCRIPT_LATIN: Latin
451 @G_UNICODE_SCRIPT_MALAYALAM: Malayalam
452 @G_UNICODE_SCRIPT_MONGOLIAN: Mongolian
453 @G_UNICODE_SCRIPT_MYANMAR: Myanmar
454 @G_UNICODE_SCRIPT_OGHAM: Ogham
455 @G_UNICODE_SCRIPT_OLD_ITALIC: Old Italic
456 @G_UNICODE_SCRIPT_ORIYA: Oriya
457 @G_UNICODE_SCRIPT_RUNIC: Runic
458 @G_UNICODE_SCRIPT_SINHALA: Sinhala
459 @G_UNICODE_SCRIPT_SYRIAC: Syriac
460 @G_UNICODE_SCRIPT_TAMIL: Tamil
461 @G_UNICODE_SCRIPT_TELUGU: Telugu
462 @G_UNICODE_SCRIPT_THAANA: Thaana
463 @G_UNICODE_SCRIPT_THAI: Thai
464 @G_UNICODE_SCRIPT_TIBETAN: Tibetan
465 @G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL:
467 @G_UNICODE_SCRIPT_YI: Yi
468 @G_UNICODE_SCRIPT_TAGALOG: Tagalog
469 @G_UNICODE_SCRIPT_HANUNOO: Hanunoo
470 @G_UNICODE_SCRIPT_BUHID: Buhid
471 @G_UNICODE_SCRIPT_TAGBANWA: Tagbanwa
472 @G_UNICODE_SCRIPT_BRAILLE: Braille
473 @G_UNICODE_SCRIPT_CYPRIOT: Cypriot
474 @G_UNICODE_SCRIPT_LIMBU: Limbu
475 @G_UNICODE_SCRIPT_OSMANYA: Osmanya
476 @G_UNICODE_SCRIPT_SHAVIAN: Shavian
477 @G_UNICODE_SCRIPT_LINEAR_B: Linear B
478 @G_UNICODE_SCRIPT_TAI_LE: Tai Le
479 @G_UNICODE_SCRIPT_UGARITIC: Ugaritic
480 @G_UNICODE_SCRIPT_NEW_TAI_LUE: New Tai Lue
481 @G_UNICODE_SCRIPT_BUGINESE: Buginese
482 @G_UNICODE_SCRIPT_GLAGOLITIC: Glagolitic
483 @G_UNICODE_SCRIPT_TIFINAGH: Tifinagh
484 @G_UNICODE_SCRIPT_SYLOTI_NAGRI: Syloti Nagri
485 @G_UNICODE_SCRIPT_OLD_PERSIAN: Old Persian
486 @G_UNICODE_SCRIPT_KHAROSHTHI: Kharoshthi
487 @G_UNICODE_SCRIPT_UNKNOWN: an unassigned code point
488 @G_UNICODE_SCRIPT_BALINESE: Balinese
489 @G_UNICODE_SCRIPT_CUNEIFORM: Cuneiform
490 @G_UNICODE_SCRIPT_PHOENICIAN: Phoenician
491 @G_UNICODE_SCRIPT_PHAGS_PA: Phags-pa
492 @G_UNICODE_SCRIPT_NKO: N'Ko
493 @G_UNICODE_SCRIPT_KAYAH_LI: Kayah Li. Since 2.16.3
494 @G_UNICODE_SCRIPT_LEPCHA: Lepcha. Since 2.16.3
495 @G_UNICODE_SCRIPT_REJANG: Rejang. Since 2.16.3
496 @G_UNICODE_SCRIPT_SUNDANESE: Sundanese. Since 2.16.3
497 @G_UNICODE_SCRIPT_SAURASHTRA: Saurashtra. Since 2.16.3
498 @G_UNICODE_SCRIPT_CHAM: Cham. Since 2.16.3
499 @G_UNICODE_SCRIPT_OL_CHIKI: Ol Chiki. Since 2.16.3
500 @G_UNICODE_SCRIPT_VAI: Vai. Since 2.16.3
501 @G_UNICODE_SCRIPT_CARIAN: Carian. Since 2.16.3
502 @G_UNICODE_SCRIPT_LYCIAN: Lycian. Since 2.16.3
503 @G_UNICODE_SCRIPT_LYDIAN: Lydian. Since 2.16.3
505 <!-- ##### FUNCTION g_unichar_get_script ##### -->
514 <!-- ##### MACRO g_utf8_next_char ##### -->
516 Skips to the next character in a UTF-8 string. The string must be
517 valid; this macro is as fast as possible, and has no error-checking.
518 You would use this macro to iterate over a string character by
519 character. The macro returns the start of the next UTF-8 character.
520 Before using this macro, use g_utf8_validate() to validate strings
521 that may contain invalid UTF-8.
524 @p: Pointer to the start of a valid UTF-8 character.
527 <!-- ##### FUNCTION g_utf8_get_char ##### -->
536 <!-- ##### FUNCTION g_utf8_get_char_validated ##### -->
546 <!-- ##### FUNCTION g_utf8_offset_to_pointer ##### -->
556 <!-- ##### FUNCTION g_utf8_pointer_to_offset ##### -->
566 <!-- ##### FUNCTION g_utf8_prev_char ##### -->
575 <!-- ##### FUNCTION g_utf8_find_next_char ##### -->
585 <!-- ##### FUNCTION g_utf8_find_prev_char ##### -->
595 <!-- ##### FUNCTION g_utf8_strlen ##### -->
605 <!-- ##### FUNCTION g_utf8_strncpy ##### -->
616 <!-- ##### FUNCTION g_utf8_strchr ##### -->
627 <!-- ##### FUNCTION g_utf8_strrchr ##### -->
638 <!-- ##### FUNCTION g_utf8_strreverse ##### -->
648 <!-- ##### FUNCTION g_utf8_validate ##### -->
659 <!-- ##### FUNCTION g_utf8_strup ##### -->
669 <!-- ##### FUNCTION g_utf8_strdown ##### -->
679 <!-- ##### FUNCTION g_utf8_casefold ##### -->
689 <!-- ##### FUNCTION g_utf8_normalize ##### -->
700 <!-- ##### ENUM GNormalizeMode ##### -->
702 Defines how a Unicode string is transformed in a canonical
703 form, standardizing such issues as whether a character with an accent is
704 represented as a base character and combining accent or as a single precomposed
705 character. Unicode strings should generally be normalized before comparing them.
708 @G_NORMALIZE_DEFAULT: standardize differences that do not affect the
709 text content, such as the above-mentioned accent representation.
710 @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT.
711 @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with composed
712 forms rather than a maximally decomposed form.
713 @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE.
714 @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the
715 "compatibility" characters in Unicode, such as SUPERSCRIPT THREE to the
716 standard forms (in this case DIGIT THREE). Formatting information may be
717 lost but for most text operations such characters should be considered the
719 @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL.
720 @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed
721 forms rather than a maximally decomposed form.
722 @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE.
724 <!-- ##### FUNCTION g_utf8_collate ##### -->
734 <!-- ##### FUNCTION g_utf8_collate_key ##### -->
744 <!-- ##### FUNCTION g_utf8_collate_key_for_filename ##### -->
754 <!-- ##### FUNCTION g_utf8_to_utf16 ##### -->
767 <!-- ##### FUNCTION g_utf8_to_ucs4 ##### -->
780 <!-- ##### FUNCTION g_utf8_to_ucs4_fast ##### -->
791 <!-- ##### FUNCTION g_utf16_to_ucs4 ##### -->
804 <!-- ##### FUNCTION g_utf16_to_utf8 ##### -->
817 <!-- ##### FUNCTION g_ucs4_to_utf16 ##### -->
830 <!-- ##### FUNCTION g_ucs4_to_utf8 ##### -->
843 <!-- ##### FUNCTION g_unichar_to_utf8 ##### -->