Details
gunichar
typedef guint32 gunichar; |
gunichar2
typedef guint16 gunichar2; |
g_get_charset ()
Obtains the character set for the current locale; you might use
this character set as an argument to g_convert(), to convert from
the current locale's encoding to some other encoding. (Frequently
g_locale_to_utf8() and g_locale_from_utf8() are nice shortcuts,
though.)
The return value is TRUE if the locale's encoding is UTF-8, in that
case you can perhaps avoid calling g_convert().
The string returned in charset is not allocated, and should not be
freed.
g_unichar_validate ()
Checks whether ch is a valid Unicode character. Some possible
integer values of ch will not be valid. 0 is considered a valid
character, though it's normally a string terminator.
g_unichar_isalnum ()
Determines whether a character is alphanumeric.
Given some UTF-8 text, obtain a character value
with g_utf8_get_char().
g_unichar_isalpha ()
Determines whether a character is alphabetic (i.e. a letter).
Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_iscntrl ()
Determines whether a character is a control character.
Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_isdigit ()
Determines whether a character is numeric (i.e. a digit). This
covers ASCII 0-9 and also digits in other languages/scripts. Given
some UTF-8 text, obtain a character value with g_utf8_get_char().
g_unichar_isgraph ()
Determines whether a character is printable and not a space
(returns FALSE for control characters, format characters, and
spaces). g_unichar_isprint() is similar, but returns TRUE for
spaces. Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_islower ()
Determines whether a character is a lowercase letter.
Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_isprint ()
Determines whether a character is printable.
Unlike g_unichar_isgraph(), returns TRUE for spaces.
Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_ispunct ()
Determines whether a character is punctuation or a symbol.
Given some UTF-8 text, obtain a character value with
g_utf8_get_char().
g_unichar_isspace ()
Determines whether a character is a space, tab, or line separator
(newline, carriage return, etc.). Given some UTF-8 text, obtain a
character value with g_utf8_get_char().
(Note: don't use this to do word breaking; you have to use
Pango or equivalent to get word breaking right, the algorithm
is fairly complex.)
g_unichar_isupper ()
Determines if a character is uppercase.
g_unichar_isxdigit ()
Determines if a characters is a hexidecimal digit
g_unichar_istitle ()
Determines if a character is titlecase. Some characters in
Unicode which are composites, such as the DZ digraph
have three case variants instead of just two. The titlecase
form is used at the beginning of a word where only the
first letter is capitalized. The titlecase form of the DZ
digraph is U+01F2 LATIN CAPITAL LETTTER D WITH SMALL LETTER Z
g_unichar_isdefined ()
Determines if a given character is assigned in the Unicode
standard.
g_unichar_iswide ()
Determines if a character is typically rendered in a double-width
cell.
g_unichar_toupper ()
Convert a character to uppercase.
g_unichar_tolower ()
Convert a character to lower case
g_unichar_totitle ()
Convert a character to the titlecase
g_unichar_digit_value ()
Determines the numeric value of a character as a decimal
digit.
g_unichar_xdigit_value ()
Determines the numeric value of a character as a hexidecimal
digit.
enum GUnicodeType
typedef enum
{
G_UNICODE_CONTROL,
G_UNICODE_FORMAT,
G_UNICODE_UNASSIGNED,
G_UNICODE_PRIVATE_USE,
G_UNICODE_SURROGATE,
G_UNICODE_LOWERCASE_LETTER,
G_UNICODE_MODIFIER_LETTER,
G_UNICODE_OTHER_LETTER,
G_UNICODE_TITLECASE_LETTER,
G_UNICODE_UPPERCASE_LETTER,
G_UNICODE_COMBINING_MARK,
G_UNICODE_ENCLOSING_MARK,
G_UNICODE_NON_SPACING_MARK,
G_UNICODE_DECIMAL_NUMBER,
G_UNICODE_LETTER_NUMBER,
G_UNICODE_OTHER_NUMBER,
G_UNICODE_CONNECT_PUNCTUATION,
G_UNICODE_DASH_PUNCTUATION,
G_UNICODE_CLOSE_PUNCTUATION,
G_UNICODE_FINAL_PUNCTUATION,
G_UNICODE_INITIAL_PUNCTUATION,
G_UNICODE_OTHER_PUNCTUATION,
G_UNICODE_OPEN_PUNCTUATION,
G_UNICODE_CURRENCY_SYMBOL,
G_UNICODE_MODIFIER_SYMBOL,
G_UNICODE_MATH_SYMBOL,
G_UNICODE_OTHER_SYMBOL,
G_UNICODE_LINE_SEPARATOR,
G_UNICODE_PARAGRAPH_SEPARATOR,
G_UNICODE_SPACE_SEPARATOR
} GUnicodeType; |
g_unichar_type ()
Classifies a unicode character by type.
enum GUnicodeBreakType
typedef enum
{
G_UNICODE_BREAK_MANDATORY,
G_UNICODE_BREAK_CARRIAGE_RETURN,
G_UNICODE_BREAK_LINE_FEED,
G_UNICODE_BREAK_COMBINING_MARK,
G_UNICODE_BREAK_SURROGATE,
G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
G_UNICODE_BREAK_INSEPARABLE,
G_UNICODE_BREAK_NON_BREAKING_GLUE,
G_UNICODE_BREAK_CONTINGENT,
G_UNICODE_BREAK_SPACE,
G_UNICODE_BREAK_AFTER,
G_UNICODE_BREAK_BEFORE,
G_UNICODE_BREAK_BEFORE_AND_AFTER,
G_UNICODE_BREAK_HYPHEN,
G_UNICODE_BREAK_NON_STARTER,
G_UNICODE_BREAK_OPEN_PUNCTUATION,
G_UNICODE_BREAK_CLOSE_PUNCTUATION,
G_UNICODE_BREAK_QUOTATION,
G_UNICODE_BREAK_EXCLAMATION,
G_UNICODE_BREAK_IDEOGRAPHIC,
G_UNICODE_BREAK_NUMERIC,
G_UNICODE_BREAK_INFIX_SEPARATOR,
G_UNICODE_BREAK_SYMBOL,
G_UNICODE_BREAK_ALPHABETIC,
G_UNICODE_BREAK_PREFIX,
G_UNICODE_BREAK_POSTFIX,
G_UNICODE_BREAK_COMPLEX_CONTEXT,
G_UNICODE_BREAK_AMBIGUOUS,
G_UNICODE_BREAK_UNKNOWN
} GUnicodeBreakType; |
g_unichar_break_type ()
Determines the break type of c. c should be a Unicode character
(to derive a character from UTF-8 encoded text, use
g_utf8_get_char()). The break type is used to find word and line
breaks ("text boundaries"), Pango implements the Unicode boundary
resolution alogorithms and normally you would use a function such
as pango_break() instead of caring about break types yourself.
g_unicode_canonical_ordering ()
g_unicode_canonical_decomposition ()
g_utf8_next_char()
#define g_utf8_next_char(p) |
Skips to the next character in a UTF-8 string. The string must be
valid; this macro is as fast as possible, and has zero error-checking.
You would use this macro to iterate over a string character by
character. The macro returns the start of the next UTF-8 character.
Before using this macro, use g_utf8_validate() to validate strings
that may contain invalid UTF-8.
g_utf8_get_char ()
Convert a sequence of bytes encoded as UTF-8 to a unicode character.
If p does not point to a valid UTF-8 encoded character, results are
undefined. If you are not sure that the bytes are complete
valid unicode characters, you should use g_utf8_get_char_validated()
instead.
g_utf8_get_char_validated ()
Convert a sequence of bytes encoded as UTF-8 to a unicode character.
This function checks for incomplete characters, for invalid characters
such as characters that are out of the range of Unicode, and for
overlong encodings of valid characters.
Return value: the resulting character. If p points to a partial
sequence at the end of a string that could begin a valid character,
g_utf8_offset_to_pointer ()
Converts from an integer character offset to a pointer to a position
within the string.
g_utf8_pointer_to_offset ()
Converts from a pointer to position within a string to a integer
character offset
g_utf8_prev_char ()
Find the previous UTF-8 character in the string before p.
p does not have to be at the beginning of a UTF-8 character. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte. If p might be the first
character of the string, you must use g_utf8_find_prev_char instead.
g_utf8_find_next_char ()
Find the start of the next utf-8 character in the string after p
p does not have to be at the beginning of a UTF-8 chracter. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.
g_utf8_find_prev_char ()
Given a position p with a UTF-8 encoded string str, find the start
of the previous UTF-8 character starting before p. Returns NULL if no
UTF-8 characters are present in p before str.
p does not have to be at the beginning of a UTF-8 chracter. No check
is made to see if the character found is actually valid other than
it starts with an appropriate byte.
g_utf8_strncpy ()
Like the standard C strncpy() function, but copies a given number
of characters instead of a given number of bytes. The src string
must be valid UTF-8 encoded text. (Use g_utf8_validate() on all
text before trying to use UTF-8 utility functions with it.)
g_utf8_strchr ()
Find the leftmost occurence of the given iso-10646 character
in a UTF-8 string, while limiting the search to p_len bytes.
If len is -1, allow unbounded search.
g_utf8_strrchr ()
Find the rightmost occurence of the given iso-10646 character
in a UTF-8 string, while limiting the search to p_len bytes.
If len is -1, allow unbounded search.
g_utf8_validate ()
Validates UTF-8 encoded text. str is the text to validate;
if str is nul-terminated, then max_len can be -1, otherwise
max_len should be the number of bytes to validate.
If end is non-NULL, then the end of the valid range
will be stored there (i.e. the address of the first invalid byte
if some bytes were invalid, or the end of the text being validated
otherwise).
Returns TRUE if all of str was valid. Many GLib and GTK+
routines <emphasis>require</emphasis> valid UTF8 as input;
so data read from a file or the network should be checked
with g_utf8_validate() before doing anything else with it.
g_utf8_strup ()
Converts all Unicode characters in the string that have a case
to uppercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string increasing. (For instance, the
German ess-zet will be changed to SS.)
g_utf8_strdown ()
Converts all Unicode characters in the string that have a case
to lowercase. The exact manner that this is done depends
on the current locale, and may result in the number of
characters in the string changing.
g_utf8_casefold ()
Converts a string into a form that is independent of case. The
result will not correspond to any particular case, but can be
compared for equality or ordered with the results of calling
g_utf8_casefold() on other strings.
Note that calling g_utf8_casefold() followed by g_utf8_collate() is
only an approximation to the correct linguistic case insensitive
ordering, though it is a fairly good one. Getting this exactly
right would require a more sophisticated collation function that
takes case sensitivity into account. GLib does not currently
provide such a function.
g_utf8_normalize ()
Convert a string into canonical form, standardizing
such issues as whether a character with an accent
is represented as a base character and combining
accent or as a single precomposed characters. You
should generally call g_utf8_normalize before
comparing two Unicode strings.
The normalization mode G_NORMALIZE_DEFAULT only
standardizes differences that do not affect the
text content, such as the above-mentioned accent
representation. G_NORMALIZE_ALL also standardizes
the "compatibility" characters in Unicode, such
as SUPERSCRIPT THREE to the standard forms
(in this case DIGIT THREE). Formatting information
may be lost but for most text operations such
characters should be considered the same.
For example, g_utf8_collate() normalizes
with G_NORMALIZE_ALL as its first step.
G_NORMALIZE_DEFAULT_COMPOSE and G_NORMALIZE_ALL_COMPOSE
are like G_NORMALIZE_DEFAULT and G_NORMALIZE_ALL,
but returned a result with composed forms rather
than a maximally decomposed form. This is often
useful if you intend to convert the string to
a legacy encoding or pass it to a system with
less capable Unicode handling.
enum GNormalizeMode
typedef enum {
G_NORMALIZE_DEFAULT,
G_NORMALIZE_NFD = G_NORMALIZE_DEFAULT,
G_NORMALIZE_DEFAULT_COMPOSE,
G_NORMALIZE_NFC = G_NORMALIZE_DEFAULT_COMPOSE,
G_NORMALIZE_ALL,
G_NORMALIZE_NFKD = G_NORMALIZE_ALL,
G_NORMALIZE_ALL_COMPOSE,
G_NORMALIZE_NFKC = G_NORMALIZE_ALL_COMPOSE
} GNormalizeMode; |
g_utf8_collate ()
Compares two strings for ordering using the linguistically
correct rules for the current locale. When sorting a large
number of strings, it will be significantly faster to
obtain collation keys with g_utf8_collate_key() and
compare the keys with strcmp() when sorting instead of
sorting the original strings.
g_utf8_collate_key ()
Converts a string into a collation key that can be compared
with other collation keys using strcmp(). The results of
comparing the collation keys of two strings with strcmp()
will always be the same as comparing the two original
keys with g_utf8_collate().
g_utf8_to_utf16 ()
Convert a string from UTF-8 to UTF-16. A 0 word will be
added to the result after the converted text.
g_utf8_to_ucs4 ()
Convert a string from UTF-8 to a 32-bit fixed width
representation as UCS-4. A trailing 0 will be added to the
string after the converted text.
g_utf8_to_ucs4_fast ()
Convert a string from UTF-8 to a 32-bit fixed width
representation as UCS-4, assuming valid UTF-8 input.
This function is roughly twice as fast as g_utf8_to_ucs4()
but does no error checking on the input.
g_utf16_to_ucs4 ()
Convert a string from UTF-16 to UCS-4. The result will be
terminated with a 0 character.
g_utf16_to_utf8 ()
Convert a string from UTF-16 to UTF-8. The result will be
terminated with a 0 byte.
g_ucs4_to_utf16 ()
Convert a string from UCS-4 to UTF-16. A 0 word will be
added to the result after the converted text.
g_ucs4_to_utf8 ()
Convert a string from a 32-bit fixed width representation as UCS-4.
to UTF-8. The result will be terminated with a 0 byte.
g_unichar_to_utf8 ()
Convert a single character to utf8