Tizen Native API  8.0

Uset module allows to specify a subset of character used in strings.

Required Header

#include <utils_i18n.h>

Overview

Uset module allows to specify a subset of character used in strings.

Functions

int i18n_uset_create_empty (i18n_uset_h *set)
 Creates an empty i18n_uset_h object.
int i18n_uset_create (i18n_uchar32 start, i18n_uchar32 end, i18n_uset_h *set)
 Creates an i18n_uset_h object that contains the range of characters start..end, inclusive.
int i18n_uset_create_pattern (const i18n_uchar *pattern, int32_t pattern_length, i18n_uset_h *set)
 Creates a set based on a given pattern.
int i18n_uset_create_pattern_options (const i18n_uchar *pattern, int32_t pattern_length, uint32_t options, i18n_uset_h *set)
 Creates a set based on a given pattern.
int i18n_uset_destroy (i18n_uset_h set)
 Disposes of the storage used by a i18n_uset_h object.
int i18n_uset_clone (const i18n_uset_h set, i18n_uset_h *set_clone)
 Returns a copy of this object.
i18n_ubool i18n_uset_is_frozen (const i18n_uset_h set)
 Determines whether the set has been frozen (made immutable) or not.
int i18n_uset_freeze (i18n_uset_h set)
 Freezes the set (make it immutable).
int i18n_uset_clone_as_thawed (const i18n_uset_h set, i18n_uset_h *set_copy)
 Clones the set and make the clone mutable.
int i18n_uset_set (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end)
 Causes the i18n_uset_h object to represent the range start - end.
int32_t i18n_uset_apply_pattern (i18n_uset_h set, const i18n_uchar *pattern, int32_t pattern_length, uint32_t options)
 Modifies the set to represent the set specified by the given pattern.
int i18n_uset_apply_int_property_value (i18n_uset_h set, i18n_uchar_uproperty_e prop, int32_t value)
 Modifies the set to contain those code points which have the given value for the given binary or enumerated property, as returned by i18n_uchar_get_int_property_value().
int i18n_uset_apply_property_alias (i18n_uset_h set, const i18n_uchar *prop, int32_t prop_length, const i18n_uchar *value, int32_t value_length)
 Modifies the set to contain those code points which have the given value for the given property.
i18n_ubool i18n_uset_resembles_pattern (const i18n_uchar *pattern, int32_t pattern_length, int32_t pos)
 Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern.
int32_t i18n_uset_to_pattern (const i18n_uset_h set, i18n_uchar *result, int32_t result_capacity, i18n_ubool escape_unprintable)
 Returns a string representation of the given set.
int i18n_uset_add (i18n_uset_h set, i18n_uchar32 character)
 Adds the given character to the given i18n_uset_h.
int i18n_uset_add_all (i18n_uset_h set, const i18n_uset_h additional_set)
 Adds all of the elements in the specified set to this set if they are not already present.
int i18n_uset_add_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end)
 Adds the given range of characters to the given i18n_uset_h. After this call, i18n_uset_contains(set, start, end) will return true. A frozen set will not be modified.
int i18n_uset_add_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len)
 Adds the given string to the given i18n_uset_h.
int i18n_uset_add_all_code_points (i18n_uset_h set, const i18n_uchar *str, int32_t str_len)
 Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}.
int i18n_uset_remove (i18n_uset_h set, i18n_uchar32 character)
 Removes the given character from the given i18n_uset_h.
int i18n_uset_remove_range (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end)
 Removes the given range of characters from the given i18n_uset_h.
int i18n_uset_remove_string (i18n_uset_h set, const i18n_uchar *str, int32_t str_len)
 Removes the given string to the given i18n_uset_h.
int i18n_uset_remove_all (i18n_uset_h set, const i18n_uset_h remove_set)
 Removes from this set all of its elements that are contained in the specified set.
int i18n_uset_retain (i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end)
 Retains only the elements in this set that are contained in the specified range.
int i18n_uset_retain_all (i18n_uset_h set, const i18n_uset_h retain)
 Retains only the elements in this set that are contained in the specified set.
int i18n_uset_compact (i18n_uset_h set)
 Reallocates this objects internal structures to take up the least possible space, without changing this object's value.
int i18n_uset_complement (i18n_uset_h set)
 Inverts this set. This operation modifies this set so that its value is its complement.
int i18n_uset_complement_all (i18n_uset_h set, const i18n_uset_h complement)
 Complements in this set all elements contained in the specified set.
int i18n_uset_clear (i18n_uset_h set)
 Removes all of the elements from this set.
int i18n_uset_destroy_over (i18n_uset_h set, int32_t attributes)
 Closes this set over the given attribute.
int i18n_uset_remove_all_strings (i18n_uset_h set)
 Removes all strings from this set.
i18n_ubool i18n_uset_is_empty (const i18n_uset_h set)
 Returns true if the given i18n_uset_h contains no characters and no strings.
i18n_ubool i18n_uset_contains (const i18n_uset_h set, i18n_uchar32 character)
 Returns true if the given i18n_uset_h contains the given character.
i18n_ubool i18n_uset_contains_range (const i18n_uset_h set, i18n_uchar32 start, i18n_uchar32 end)
 Returns true if the given i18n_uset_h contains all characters c where start <= c && c <= end.
i18n_ubool i18n_uset_contains_string (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len)
 Returns true if the given i18n_uset_h contains the given string.
int32_t i18n_uset_index_of (const i18n_uset_h set, i18n_uchar32 character)
 Returns the index of the given character within this set, where the set is ordered by ascending code point.
i18n_uchar32 i18n_uset_char_at (const i18n_uset_h set, int32_t char_index)
 Returns the character at the given index within this set, where the set is ordered by ascending code point.
int32_t i18n_uset_size (const i18n_uset_h set)
 Returns the number of characters and strings contained in the given i18n_uset_h.
int32_t i18n_uset_get_item_count (const i18n_uset_h set)
 Returns the number of items in this set.
int32_t i18n_uset_get_item (const i18n_uset_h set, int32_t item_index, i18n_uchar32 *start, i18n_uchar32 *end, i18n_uchar *str, int32_t str_capacity)
 Returns an item of this set.
i18n_ubool i18n_uset_contains_all (const i18n_uset_h set1, const i18n_uset_h set2)
 Returns true if set1 contains all the characters and strings of set2. It answers the question, 'Is set1 a superset of set2?'.
i18n_ubool i18n_uset_contains_all_code_points (const i18n_uset_h set, const i18n_uchar *str, int32_t str_len)
 Returns true if this set contains all the characters of the given string.
i18n_ubool i18n_uset_contains_none (const i18n_uset_h set1, const i18n_uset_h set2)
 Returns true if set1 contains none of the characters and strings of set2.
i18n_ubool i18n_uset_contains_some (const i18n_uset_h set1, const i18n_uset_h set2)
 Returns true if set1 contains some of the characters and strings of set2.
int32_t i18n_uset_span (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition)
 Returns the length of the initial substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).
int32_t i18n_uset_span_back (const i18n_uset_h set, const i18n_uchar *str, int32_t length, i18n_uset_span_condition_e span_condition)
 Returns the start of the trailing substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).
int32_t i18n_uset_span_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition)
 Returns the length of the initial substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).
int32_t i18n_uset_span_back_utf8 (const i18n_uset_h set, const char *str, int32_t length, i18n_uset_span_condition_e span_condition)
 Returns the start of the trailing substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).
i18n_ubool i18n_uset_equals (const i18n_uset_h set1, const i18n_uset_h set2)
 Returns true if set1 contains all of the characters and strings of set2, and vice versa. It answers the question, 'Is set1 equal to set2?'.
int32_t i18n_uset_serialize (const i18n_uset_h set, uint16_t *dest, int32_t dest_capacity)
 Serializes this set into an array of 16-bit integers.
i18n_ubool i18n_uset_get_serialized_set (const uint16_t *src, int32_t src_length, i18n_userialized_set_s *fill_set)
 Given a serialized array, fill in the given serialized set object.
int i18n_uset_set_serialized_to_one (i18n_uchar32 character, i18n_userialized_set_s *fill_set)
 Sets the i18n_userialized_set_s to contain the given character (and nothing else).
i18n_ubool i18n_uset_serialized_contains (const i18n_userialized_set_s *set, i18n_uchar32 character)
 Returns true if the given i18n_userialized_set_s contains the given character.
int32_t i18n_uset_get_serialized_range_count (const i18n_userialized_set_s *set)
 Returns the number of disjoint ranges of characters contained in the given serialized set.
i18n_ubool i18n_uset_get_serialized_range (const i18n_userialized_set_s *set, int32_t range_index, i18n_uchar32 *p_start, i18n_uchar32 *p_end)
 Returns a range of characters contained in the given serialized set.

Typedefs

typedef void * i18n_uset_h
 An i18n_uset_h handle.

Defines

#define I18N_USET_SERIALIZED_STATIC_ARRAY_CAPACITY   8
 Capacity of i18n_userialized_set_s::static_array. Enough for any single-code point set.

Define Documentation

Capacity of i18n_userialized_set_s::static_array. Enough for any single-code point set.

Since :
2.3.1
See also:
i18n_userialized_set_s

Typedef Documentation

typedef void* i18n_uset_h

An i18n_uset_h handle.

Use the i18n_uset_* API to manipulate. Create with i18n_uset_create*, and destroy with i18n_uset_destroy().

Since :
2.3.1

Enumeration Type Documentation

anonymous enum

Enumeration for bitmask values to be passed to i18n_uset_pattern_options_create() or i18n_uset_apply_pattern() taking an option parameter.

Since :
2.3.1
Enumerator:
I18N_USET_IGNORE_SPACE 

Ignore white space within patterns unless quoted or escaped.

I18N_USET_CASE_INSENSITIVE 

Enable case insensitive matching. E.g., "[ab]" with this flag will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will match all except 'a', 'A', 'b', and 'B'. This performs a full closure over case mappings, e.g. U+017F for s.

The resulting set is a superset of the input for the code points but not for the strings. It performs a case mapping closure of the code points and adds full case folding strings for the code points, and reduces strings of the original set to their full case folding equivalents.

This is designed for case-insensitive matches, for example in regular expressions. The full code point case closure allows checking of an input character directly against the closure set. Strings are matched by comparing the case-folded form from the closure set with an incremental case folding of the string in question.

The closure set will also contain single code points if the original set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.). This is not necessary (that is, redundant) for the above matching method but results in the same closure sets regardless of whether the original set contained the code point or a string.

I18N_USET_ADD_CASE_MAPPINGS 

Enable case insensitive matching. E.g., "[ab]" with this flag will match 'a', 'A', 'b', and 'B'. "[^ab]" with this flag will match all except 'a', 'A', 'b', and 'B'. This adds the lower-, title-, and uppercase mappings as well as the case folding of each existing element in the set.

Enumeration for span conditions.

Since :
2.3.1
See also:
i18n_uset_span()
i18n_uset_span_back()
i18n_uset_span_utf8()
i18n_uset_span_back_utf8()
Enumerator:
I18N_USET_SPAN_NOT_CONTAINED 

Continue a span() while there is no set element at the current position. Stops before the first set element (character or string). (For code points only, this is like while contains(current) == false).

When span() returns, the substring between where it started and the position it returned consists only of characters that are not in the set, and none of its strings overlap with the span.

I18N_USET_SPAN_CONTAINED 

Continue a span() while there is a set element at the current position. (For characters only, this is like while contains(current) == true).

When span() returns, the substring between where it started and the position it returned consists only of set elements (characters or strings) that are in the set.

If a set contains strings, then the span will be the longest substring matching any of the possible concatenations of set elements (characters or strings). (There must be a single, non-overlapping concatenation of characters or strings.) This is equivalent to a POSIX regular expression for (OR of each set element).

I18N_USET_SPAN_SIMPLE 

Continue a span() while there is a set element at the current position. (For characters only, this is like while contains(current) == true).

When span() returns, the substring between where it started and the position it returned consists only of set elements (characters or strings) that are in the set.

If a set only contains single characters, then this is the same as I18N_USET_SPAN_CONTAINED.

If a set contains strings, then the span will be the longest substring with a match at each position with the longest single set element (character or string).

I18N_USET_SPAN_CONDITION_COUNT 

One more than the last span condition.


Function Documentation

int i18n_uset_add ( i18n_uset_h  set,
i18n_uchar32  character 
)

Adds the given character to the given i18n_uset_h.

After this call, i18n_uset_contains(set, character) will return true. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]characterThe character to add.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains()
int i18n_uset_add_all ( i18n_uset_h  set,
const i18n_uset_h  additional_set 
)

Adds all of the elements in the specified set to this set if they are not already present.

This operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the set. Must not be NULL.
[in]additional_setThe source set whose elements are to be added to this set.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_add_all_code_points ( i18n_uset_h  set,
const i18n_uchar str,
int32_t  str_len 
)

Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}.

If this set already any particular character, it has no effect on that character. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]strThe source string.
[in]str_lenThe length of the string, >= 0, or -1 if NULL terminated.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_add_range ( i18n_uset_h  set,
i18n_uchar32  start,
i18n_uchar32  end 
)

Adds the given range of characters to the given i18n_uset_h. After this call, i18n_uset_contains(set, start, end) will return true. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]startThe first character of the range to add, inclusive
[in]endThe last character of the range to add, inclusive
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains()
int i18n_uset_add_string ( i18n_uset_h  set,
const i18n_uchar str,
int32_t  str_len 
)

Adds the given string to the given i18n_uset_h.

After this call, i18n_uset_contains_string(set, str, str_len) will return true. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]strThe string to add.
[in]str_lenThe length of the string, >= 0, or -1 if NULL terminated.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains_string()
int i18n_uset_apply_int_property_value ( i18n_uset_h  set,
i18n_uchar_uproperty_e  prop,
int32_t  value 
)

Modifies the set to contain those code points which have the given value for the given binary or enumerated property, as returned by i18n_uchar_get_int_property_value().

Prior contents of this set are lost. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to contain the code points defined by the property. Must not be NULL.
[in]propA property in the range I18N_UCHAR_INT_START..I18N_UCHAR_INT_LIMIT-1 or I18N_UCHAR_MASK_START..I18N_UCHAR_MASK_LIMIT-1.
[in]valueA value in the range i18n_uchar_get_int_property_min_value(prop).. i18n_uchar_get_int_property_max_value(prop), with one exception. If prop is I18N_UCHAR_GENERAL_CATEGORY_MASK, then value should not be a i18n_uchar_category_e, but rather a mask value produced by I18N_U_GET_GC_MASK(). This allows grouped categories such as [:L:] to be represented.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int32_t i18n_uset_apply_pattern ( i18n_uset_h  set,
const i18n_uchar pattern,
int32_t  pattern_length,
uint32_t  options 
)

Modifies the set to represent the set specified by the given pattern.

See the UnicodeSet class description for the syntax of the pattern language. See also the User Guide chapter about UnicodeSet. Empties the set passed before applying the pattern. A frozen set will not be modified.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and in i18n_error_code_e description.
Since :
2.3.1
Parameters:
[in]setThe set to which the pattern is to be applied. Must not be NULL.
[in]patternA pointer to i18n_uchar string specifying what characters are in the set. The character at pattern[0] must be a '['.
[in]pattern_lengthThe length of the i18n_uchar string, >= 0, or -1 if NULL terminated.
[in]optionsA bitmask for options to apply to the pattern. Valid options are I18N_USET_IGNORE_SPACE and I18N_USET_CASE_INSENSITIVE.
Returns:
Upon successful parse, the value is either the index of the character after the closing ']' of the parsed pattern. If the status code indicates failure, then the return value is the index of the error in the source. If set is NULL, 0 is returned.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_apply_property_alias ( i18n_uset_h  set,
const i18n_uchar prop,
int32_t  prop_length,
const i18n_uchar value,
int32_t  value_length 
)

Modifies the set to contain those code points which have the given value for the given property.

Prior contents of this set are lost. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to contain the code points defined by the given property and value alias. Must not be NULL.
[in]propA string specifying a property alias, either short or long. The name is matched loosely. See PropertyAliases.txt for names and a description of loose matching. If the value string is empty, then this string is interpreted as either a General_Category value alias, a Script value alias, a binary property alias, or a special ID. Special IDs are matched loosely and correspond to the following sets:

"ANY" = [\u0000-\U0010FFFF], "ASCII" = [\u0000-\u007F], "Assigned" = [:^Cn:].

Parameters:
[in]prop_lengthThe length of the prop, >= 0, or -1 if NULL.
[in]valueA string specifying a value alias, either short or long. The name is matched loosely. See PropertyValueAliases.txt for names and a description of loose matching. In addition to aliases listed, numeric values and canonical combining classes may be expressed numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string may also be empty.
[in]value_lengthThe length of the value, >= 0, or -1 if NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_uchar32 i18n_uset_char_at ( const i18n_uset_h  set,
int32_t  char_index 
)

Returns the character at the given index within this set, where the set is ordered by ascending code point.

If the index is out of range, return (i18n_uchar32)-1. The inverse of this function is i18n_uset_index_of().

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
[in]char_indexAn index from 0..size()-1 to obtain the char for
Returns:
The character at the given index, or (i18n_uchar32)-1.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Removes all of the elements from this set.

This set will be empty after this call returns. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_clone ( const i18n_uset_h  set,
i18n_uset_h set_clone 
)

Returns a copy of this object.

If this set is frozen, then the clone will be frozen as well. Uses i18n_uset_clone_as_thawed() for a mutable clone of a frozen set.

Since :
2.3.1
Remarks:
The set_clone should be released using i18n_uset_destroy().
Parameters:
[in]setThe original set. Must not be NULL.
[out]set_cloneThe newly allocated copy of the set
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_clone_as_thawed()
 #include <stdio.h>
 #include <stdlib.h>
 #include <utils_i18n.h>
 int main() {
    i18n_uset_h set = NULL;
    i18n_uset_h set_clone = NULL;
    i18n_uchar32 start = 0x41;
    i18n_uchar32 end = 0x50;
    i18n_error_code_e error_code;

    error_code = i18n_uset_create(start, end, &set);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create: %d\n", error_code);
        return EXIT_FAILURE;
    }
    error_code = i18n_uset_clone(set, &set_clone);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_clone: %d\n", error_code);
        i18n_uset_destroy(set);
        return EXIT_FAILURE;
    }
    i18n_uset_destroy(set_clone);
    i18n_uset_destroy(set);
    return EXIT_SUCCESS;
 }
int i18n_uset_clone_as_thawed ( const i18n_uset_h  set,
i18n_uset_h set_copy 
)

Clones the set and make the clone mutable.

See the ICU4J Freezable interface for details.

Since :
2.3.1
Remarks:
The set_copy should be released using i18n_uset_destroy().
Parameters:
[in]setThe set. Must not be NULL.
[out]set_copyThe mutable clone
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_freeze()
i18n_uset_is_frozen()
i18n_uset_clone()
 #include <stdio.h>
 #include <stdlib.h>
 #include <utils_i18n.h>
 int main() {
    i18n_uset_h set = NULL;
    i18n_uset_h set_copy = NULL;
    i18n_uchar32 start = 0x41;
    i18n_uchar32 end = 0x50;
    i18n_error_code_e error_code;

    error_code = i18n_uset_create(start, end, &set);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create: %d\n", error_code);
        return EXIT_FAILURE;
    }
    error_code = i18n_uset_clone_as_thawed(set, &set_copy);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_clone_as_thawed: %d\n", error_code);
        i18n_uset_destroy(set);
        return EXIT_FAILURE;
    }
    i18n_uset_destroy(set_copy);
    i18n_uset_destroy(set);
    return EXIT_SUCCESS;
 }

Reallocates this objects internal structures to take up the least possible space, without changing this object's value.

A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object on which to perfrom the compact. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Inverts this set. This operation modifies this set so that its value is its complement.

This operation does not affect the multicharacter strings, if any. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_complement_all ( i18n_uset_h  set,
const i18n_uset_h  complement 
)

Complements in this set all elements contained in the specified set.

Any character in the other set will be removed if it is in this set, or will be added if it is not in this set. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe set with which to complement. Must not be NULL.
[in]complementSet that defines which elements will be xor'ed from this set. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains ( const i18n_uset_h  set,
i18n_uchar32  character 
)

Returns true if the given i18n_uset_h contains the given character.

This function works faster with a frozen set.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]characterthe codepoint to check for within the set
Returns:
true if set contains the given character
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains_all ( const i18n_uset_h  set1,
const i18n_uset_h  set2 
)

Returns true if set1 contains all the characters and strings of set2. It answers the question, 'Is set1 a superset of set2?'.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]set1Set to be checked for containment. Must not be NULL.
[in]set2Set to be checked for containment. Must not be NULL.
Returns:
true if the test condition is met
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains_all_code_points ( const i18n_uset_h  set,
const i18n_uchar str,
int32_t  str_len 
)

Returns true if this set contains all the characters of the given string.

This is does not check containment of grapheme clusters, like i18n_uset_contains_string().

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setSet of characters to be checked for containment. Must not be NULL.
[in]strString containing codepoints to be checked for containment
[in]str_lenThe length of the string, >= 0, or -1 if NULL terminated.
Returns:
true if the test condition is met.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains_none ( const i18n_uset_h  set1,
const i18n_uset_h  set2 
)

Returns true if set1 contains none of the characters and strings of set2.

It answers the question, 'Is set1 a disjoint set of set2?'

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]set1Set to be checked for containment. Must not be NULL.
[in]set2Set to be checked for containment. Must not be NULL.
Returns:
true if the test condition is met
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Returns true if the given i18n_uset_h contains all characters c where start <= c && c <= end.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
[in]startThe first character of the range to test, inclusive
[in]endThe last character of the range to test, inclusive
Returns:
true if set contains the range
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains_some ( const i18n_uset_h  set1,
const i18n_uset_h  set2 
)

Returns true if set1 contains some of the characters and strings of set2.

It answers the question, 'Does set1 and set2 have an intersection?'

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]set1Set to be checked for containment. Must not be NULL.
[in]set2Set to be checked for containment. Must not be NULL.
Returns:
true if the test condition is met
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_contains_string ( const i18n_uset_h  set,
const i18n_uchar str,
int32_t  str_len 
)

Returns true if the given i18n_uset_h contains the given string.

Since :
2.3.1
Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Parameters:
[in]setThe set. Must not be NULL.
[in]strThe string.
[in]str_lenThe length of the string, >= 0, or -1 if NULL terminated
Returns:
true if set contains str
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_create ( i18n_uchar32  start,
i18n_uchar32  end,
i18n_uset_h set 
)

Creates an i18n_uset_h object that contains the range of characters start..end, inclusive.

If start > end then an empty set is created (same as using i18n_uset_empty_create()).

Since :
2.3.1
Remarks:
The set should be released using i18n_uset_destroy().
Parameters:
[in]startFirst character of the range, inclusive
[in]endLast character of the range, inclusive
[out]setA pointer to the newly created i18n_uset_h object. The caller must call i18n_uset_destroy() on it when done. *
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_destroy()
 #include <stdio.h>
 #include <stdlib.h>
 #include <utils_i18n.h>
 int main() {
    i18n_uset_h set = NULL;
    i18n_uchar32 start = 0x41;
    i18n_uchar32 end = 0x50;

    i18n_error_code_e error_code;
    error_code = i18n_uset_create(start, end, &set);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create: %d\n", error_code);
        return EXIT_FAILURE;
    }
    i18n_uset_destroy(set);
    return EXIT_SUCCESS;
 }

Creates an empty i18n_uset_h object.

Equivalent to i18n_uset_create(1, 0).

Since :
2.3.1
Remarks:
The set should be released using i18n_uset_destroy().
Parameters:
[out]setA pointer to the newly created i18n_uset_h. The caller must call i18n_uset_destroy() on it when done.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
 #include <stdio.h>
 #include <stdlib.h>
 #include <utils_i18n.h>
 int main() {
    i18n_uset_h uset = NULL;
    i18n_error_code_e error_code;
    error_code = i18n_uset_create_empty(&uset);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create_empty: %d\n", error_code);
        return EXIT_FAILURE;
    }
    i18n_uset_destroy(uset);
    return EXIT_SUCCESS;
 }
See also:
i18n_uset_destroy()
int i18n_uset_create_pattern ( const i18n_uchar pattern,
int32_t  pattern_length,
i18n_uset_h set 
)

Creates a set based on a given pattern.

See the UnicodeSet class description for the syntax of the pattern language.

Since :
2.3.1
Remarks:
The set should be released using i18n_uset_destroy().
Parameters:
[in]patternA string specifying what characters are in the set
[in]pattern_lengthThe length of the pattern, >= 0, or -1 if NULL-terminated.
[out]setA pointer to the newly created i18n_uset_h object. The caller must call i18n_uset_destroy() on it when done. *
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_destroy()
 #include <stdio.h>
 #include <stdlib.h>
 #include <utils_i18n.h>
 int main() {
    const char *pattern_ascii = "[:Hyphen:]";
    i18n_uchar *pattern = NULL;
    i18n_uset_h set = NULL;
    i18n_error_code_e error_code;

    pattern = (i18n_uchar *)calloc(strlen(pattern_ascii), sizeof(i18n_uchar));
    i18n_ustring_copy_ua(pattern, pattern_ascii);

    error_code = i18n_uset_create_pattern(pattern, 10, &set);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create_pattern: %d\n", error_code);
        return EXIT_FAILURE;
    }
    free(pattern);
    i18n_uset_destroy(set);
    return EXIT_SUCCESS;
 }
int i18n_uset_create_pattern_options ( const i18n_uchar pattern,
int32_t  pattern_length,
uint32_t  options,
i18n_uset_h set 
)

Creates a set based on a given pattern.

See the UnicodeSet class description for the syntax of the pattern language.

Since :
2.3.1
Remarks:
The set should be released using i18n_uset_destroy().
Parameters:
[in]patternA string specifying what characters are in the set
[in]pattern_lengthThe length of the pattern, >= 0, or -1 if NULL-terminated
[in]optionsBitmask for options to apply to the pattern. Valid options are I18N_USET_IGNORE_SPACE and I18N_USET_CASE_INSENSITIVE.
[out]setA pointer to the newly created i18n_uset_h object. The caller must call i18n_uset_destroy() on it when done.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_destroy()
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <utils_i18n.h>
 int main() {
    const char *pattern_ascii = "[:Hyphen:]";
    i18n_uchar *pattern = NULL;
    i18n_uset_h set = NULL;
    i18n_error_code_e error_code;

    pattern = (i18n_uchar *)calloc(strlen(pattern_ascii) + 1, sizeof(i18n_uchar));
    i18n_ustring_copy_ua(pattern, pattern_ascii);

    error_code = i18n_uset_create_pattern_options(pattern, strlen(pattern_ascii), I18N_USET_IGNORE_SPACE, &set);
    if (error_code != I18N_ERROR_NONE) {
        printf("Error i18n_uset_create_pattern: %d\n", error_code);
        return EXIT_FAILURE;
    }
    free(pattern);
    i18n_uset_destroy(set);
    return EXIT_SUCCESS;
 }

Disposes of the storage used by a i18n_uset_h object.

This function should be called exactly once for objects returned by i18n_uset_create().

Since :
2.3.1
Parameters:
[in]setThe object to dispose of
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_destroy_over ( i18n_uset_h  set,
int32_t  attributes 
)

Closes this set over the given attribute.

For the attribute I18N_USET_CASE_INSENSITIVE, the result is to modify this set so that:

1. For each character or string 'a' in this set, all strings or characters 'b' such that foldCase(a) == foldCase(b) are added to this set.

2. For each string 'e' in the resulting set, if e != foldCase(e), 'e' will be removed.

Example: [aq\u00DF{Bc}{bC}{Fi}] => [aAqQ\u00DF\uFB01{ss}{bc}{fi}]

(Here foldCase(x) refers to the operation i18n_ustring_fold_case(), and a == b denotes that the contents are the same, not pointer comparison.)

A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
[in]attributesBitmask for attributes to close over. Currently only the I18N_USET_CASE_INSENSITIVE bit is supported. Any undefined bits are ignored.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_ustring_fold_case()
i18n_ubool i18n_uset_equals ( const i18n_uset_h  set1,
const i18n_uset_h  set2 
)

Returns true if set1 contains all of the characters and strings of set2, and vice versa. It answers the question, 'Is set1 equal to set2?'.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]set1Set to be checked for containment. Must not be NULL.
[in]set2Set to be checked for containment. Must not be NULL.
Returns:
true if the test condition is met
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Freezes the set (make it immutable).

Once frozen, it cannot be unfrozen and is therefore thread-safe until it is deleted. See the ICU4J Freezable interface for details. Freezing the set may also make some operations faster, for example i18n_uset_contains() and i18n_uset_span(). A frozen set will not be modified. (It remains frozen.)

Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
the same set, now frozen
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_is_frozen()
i18n_uset_clone_as_thawed()
int32_t i18n_uset_get_item ( const i18n_uset_h  set,
int32_t  item_index,
i18n_uchar32 start,
i18n_uchar32 end,
i18n_uchar str,
int32_t  str_capacity 
)

Returns an item of this set.

An item is either a range of characters or a single multicharacter string.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
[in]item_indexA non-negative integer in the range [0; i18n_uset_get_item_count(set)-1].
[in]startPointer to variable to receive first character in range, inclusive
[in]endPointer to variable to receive last character in range, inclusive
[out]strBuffer to receive the string, may be NULL
[in]str_capacityCapacity of str, or 0 if str is NULL
Returns:
The length of the string (>= 2), or 0 if the item is a range, in which case it is the range *start..*end, or -1 if item_index is out of range
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int32_t i18n_uset_get_item_count ( const i18n_uset_h  set)

Returns the number of items in this set.

An item is either a range of characters or a single multicharacter string.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
A non-negative integer counting the character ranges and/or strings contained in set.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
i18n_ubool i18n_uset_get_serialized_range ( const i18n_userialized_set_s set,
int32_t  range_index,
i18n_uchar32 p_start,
i18n_uchar32 p_end 
)

Returns a range of characters contained in the given serialized set.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe serialized set. Must not be NULL.
[in]range_indexA non-negative integer in the range 0.. i18n_uset_get_serialized_range_count(set)-1
[out]p_startPointer to variable to receive first character in range, inclusive
[out]p_endPointer to variable to receive last character in range, inclusive
Returns:
true if range_index is valid, otherwise false
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_userialized_set_s

Returns the number of disjoint ranges of characters contained in the given serialized set.

Ignores any strings contained in the set.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe serialized set. Must not be NULL.
Returns:
A non-negative integer counting the character ranges contained in set
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_userialized_set_s
i18n_ubool i18n_uset_get_serialized_set ( const uint16_t *  src,
int32_t  src_length,
i18n_userialized_set_s fill_set 
)

Given a serialized array, fill in the given serialized set object.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]srcpointer to start of array. Must not be NULL.
[in]src_lengthlength of src array, >= 0.
[out]fill_setthe serialized set to be filled
Returns:
true if the given array is valid, otherwise false
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_userialized_set_s
int32_t i18n_uset_index_of ( const i18n_uset_h  set,
i18n_uchar32  character 
)

Returns the index of the given character within this set, where the set is ordered by ascending code point.

If the character is not in this set, return -1. The inverse of this function is i18n_uset_char_at().

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]characterthe character to obtain the index for
Returns:
An index from 0..size()-1, or -1
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Returns true if the given i18n_uset_h contains no characters and no strings.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
true if set is empty
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Determines whether the set has been frozen (made immutable) or not.

See the ICU4J Freezable interface for details.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
true/false for whether the set has been frozen
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_freeze()
i18n_uset_clone_as_thawed()
int i18n_uset_remove ( i18n_uset_h  set,
i18n_uchar32  character 
)

Removes the given character from the given i18n_uset_h.

After this call, i18n_uset_contains(set, character) will return false. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setthe object from which to remove the character. Must not be NULL.
[in]characterthe character to remove
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains()
int i18n_uset_remove_all ( i18n_uset_h  set,
const i18n_uset_h  remove_set 
)

Removes from this set all of its elements that are contained in the specified set.

This operation effectively modifies this set so that its value is the asymmetric set difference of the two sets. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object from which the elements are to be removed. Must not be NULL.
[in]remove_setThe object that defines which elements will be removed from this set. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Removes all strings from this set.

Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Removes the given range of characters from the given i18n_uset_h.

After this call, i18n_uset_contains(set, start, end) will return false. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]startThe first character of the range to remove, inclusive
[in]endThe last character of the range to remove, inclusive
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains()
int i18n_uset_remove_string ( i18n_uset_h  set,
const i18n_uchar str,
int32_t  str_len 
)

Removes the given string to the given i18n_uset_h.

After this call, i18n_uset_contains_string(set, str, str_len) will return false. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to which to add the character. Must not be NULL.
[in]strThe string to remove.
[in]str_lenThe length of the string, >= 0, or -1 if NULL terminated.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_contains_string()
i18n_ubool i18n_uset_resembles_pattern ( const i18n_uchar pattern,
int32_t  pattern_length,
int32_t  pos 
)

Return true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern.

Since :
2.3.1
Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Parameters:
[in]patternA string specifying the pattern.
[in]pattern_lengthThe length of the pattern, >= 0, or -1 if NULL.
[in]posThe given position, >= 0.
Returns:
true if the given position, in the given pattern, appears to be the start of a UnicodeSet pattern.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_retain ( i18n_uset_h  set,
i18n_uchar32  start,
i18n_uchar32  end 
)

Retains only the elements in this set that are contained in the specified range.

If start > end then an empty range is retained, leaving the set empty. This is equivalent to a boolean logic AND, or a set INTERSECTION. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object for which to retain only the specified range. Must not be NULL.
[in]startFirst character, inclusive, of range to be retained to this set.
[in]endLast character, inclusive, of range to be retained to this set.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int i18n_uset_retain_all ( i18n_uset_h  set,
const i18n_uset_h  retain 
)

Retains only the elements in this set that are contained in the specified set.

In other words, removes from this set all of its elements that are not contained in the specified set. This operation effectively modifies this set so that its value is the intersection of the two sets. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object on which to perform the retain. Must not be NULL.
[in]retainSet that defines which elements this set will retain. Must not be NULL.
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int32_t i18n_uset_serialize ( const i18n_uset_h  set,
uint16_t *  dest,
int32_t  dest_capacity 
)

Serializes this set into an array of 16-bit integers.

Serialization (currently) only records the characters in the set; multicharacter strings are ignored.

The array has following format (each line is one 16-bit integer):

length = (n+2*m) | (m!=0?0x8000:0) bmpLength = n; present if m!=0 bmp[0] bmp[1] ... bmp[n-1] supp-high[0] supp-low[0] supp-high[1] supp-low[1] ... supp-high[m-1] supp-low[m-1]

The array starts with a header. After the header are n bmp code points, then m supplementary code points. Either n or m or both may be zero. n+2*m is always <= 0x7FFF.

If there are no supplementary characters (if m==0) then the header is one 16-bit integer, 'length', with value n.

If there are supplementary characters (if m!=0) then the header is two 16-bit integers. The first, 'length', has value (n+2*m)|0x8000. The second, 'bmpLength', has value n.

After the header the code points are stored in ascending order. Supplementary code points are stored as most significant 16 bits followed by least significant 16 bits.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and in i18n_error_code_e description.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[out]destpointer to buffer of dest_capacity 16-bit integers May be NULL only if dest_capacity is zero.
[in]dest_capacitysize of dest, or zero Must not be negative.
Returns:
the total length of the serialized format, including the header, that is, n+2*m+(m != 0 ? 2 : 1), or 0 on error other than I18N_ERROR_BUFFER_OVERFLOW.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
I18N_ERROR_INDEX_OUTOFBOUNDSIf n+2*m > 0x7FFF
I18N_ERROR_BUFFER_OVERFLOWIf n+2*m+(m != 0 ? 2 : 1) > dest_capacity.

Returns true if the given i18n_userialized_set_s contains the given character.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe serialized set. Must not be NULL.
[in]characterthe code point to check for within the set
Returns:
true if set contains character
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_userialized_set_s
int i18n_uset_set ( i18n_uset_h  set,
i18n_uchar32  start,
i18n_uchar32  end 
)

Causes the i18n_uset_h object to represent the range start - end.

If start > end then this i18n_uset_h is set to an empty range. A frozen set will not be modified.

Since :
2.3.1
Parameters:
[in]setThe object to set to the given range. Must not be NULL.
[in]startFirst character in the set, inclusive
[in]endLast character in the set, inclusive
Returns:
Error code. Error codes not listed below are described in i18n_error_code_e
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter

Sets the i18n_userialized_set_s to contain the given character (and nothing else).

Since :
2.3.1
Parameters:
[in]characterthe code point to set
[out]fill_setthe serialized set to be filled
Returns:
Error code.
Return values:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_userialized_set_s
int32_t i18n_uset_size ( const i18n_uset_h  set)

Returns the number of characters and strings contained in the given i18n_uset_h.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
Returns:
A non-negative integer counting the characters and strings contained in set.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
int32_t i18n_uset_span ( const i18n_uset_h  set,
const i18n_uchar str,
int32_t  length,
i18n_uset_span_condition_e  span_condition 
)

Returns the length of the initial substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).

See i18n_uset_span_condition_e for details. Similar to the strspn() C library function. Unpaired surrogates are treated according to contains() of their surrogate code points. This function works faster with a frozen set and with a non-negative string length argument.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]strstart of the input string.
[in]lengthlength of the string; >= 0, can be -1 for NULL-terminated
[in]span_conditionspecifies the containment condition
Returns:
The length of the initial substring according to the span_condition; 0 if the start of the string does not fit the span_condition
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_span_condition_e
int32_t i18n_uset_span_back ( const i18n_uset_h  set,
const i18n_uchar str,
int32_t  length,
i18n_uset_span_condition_e  span_condition 
)

Returns the start of the trailing substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).

See i18n_uset_span_condition_e for details. Unpaired surrogates are treated according to contains() of their surrogate code points. This function works faster with a frozen set and with a non-negative string length argument.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]strstart of the input string
[in]lengthlength of the str; >= 0, can be -1 for NULL-terminated
[in]span_conditionspecifies the containment condition
Returns:
the start of the trailing substring according to the span_condition; the string length if the end of the string does not fit the span_condition
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_span_condition_e
int32_t i18n_uset_span_back_utf8 ( const i18n_uset_h  set,
const char *  str,
int32_t  length,
i18n_uset_span_condition_e  span_condition 
)

Returns the start of the trailing substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).

See i18n_uset_span_condition_e for details. Malformed byte sequences are treated according to contains(0xfffd). This function works faster with a frozen set and with a non-negative string length argument.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]strstart of the string (UTF-8)
[in]lengthlength of the string; >= 0, can be -1 for NULL-terminated
[in]span_conditionspecifies the containment condition
Returns:
the start of the trailing substring according to the span_condition; the string length if the end of the string does not fit the span_condition
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_span_condition_e
int32_t i18n_uset_span_utf8 ( const i18n_uset_h  set,
const char *  str,
int32_t  length,
i18n_uset_span_condition_e  span_condition 
)

Returns the length of the initial substring of the input string which consists only of characters and strings that are contained in this set (I18N_USET_SPAN_CONTAINED, I18N_USET_SPAN_SIMPLE), or only of characters and strings that are not contained in this set (I18N_USET_SPAN_NOT_CONTAINED).

See i18n_uset_span_condition_e for details. Similar to the strspn() C library function. Malformed byte sequences are treated according to contains(0xfffd). This function works faster with a frozen set and with a non-negative string length argument.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section.
Since :
2.3.1
Parameters:
[in]setthe set. Must not be NULL.
[in]strstart of the string (UTF-8)
[in]lengthlength of the string; >= 0, can be -1 for NULL-terminated
[in]span_conditionspecifies the containment condition
Returns:
the length of the initial substring according to the span_condition; 0 if the start of the string does not fit the span_condition
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_span_condition_e
int32_t i18n_uset_to_pattern ( const i18n_uset_h  set,
i18n_uchar result,
int32_t  result_capacity,
i18n_ubool  escape_unprintable 
)

Returns a string representation of the given set.

If the result of calling this function is passed to an i18n_uset_create_pattern(), it will produce another set that is equal to this one.

Remarks:
The specific error code can be obtained using the get_last_result() method. Error codes are described in Exceptions section and in i18n_error_code_e description.
Since :
2.3.1
Parameters:
[in]setThe set. Must not be NULL.
[in,out]resultThe string to receive the rules, may be NULL.
[in]result_capacityThe capacity of result, >= 0, may be 0 if result is NULL.
[in]escape_unprintableIf true then convert unprintable character to their hex escape representations, \uxxxx or \Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E.
Returns:
Length of string, >= 0, possibly larger than result_capacity. If set is NULL, 0 is returned.
Exceptions:
I18N_ERROR_NONESuccessful
I18N_ERROR_INVALID_PARAMETERInvalid function parameter
See also:
i18n_uset_create_pattern()