#include <stddef.h>
#include <unistd.h>
#include <idn-int.h>
Go to the source code of this file.
#define stringprep_iscsi | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_iscsi) |
Definition at line 164 of file stringprep.h.
#define stringprep_kerberos5 | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_kerberos5) |
Definition at line 146 of file stringprep.h.
#define STRINGPREP_MAX_MAP_CHARS 4 |
Definition at line 77 of file stringprep.h.
#define stringprep_nameprep | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_nameprep) |
#define stringprep_nameprep_no_unassigned | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, STRINGPREP_NO_UNASSIGNED, stringprep_nameprep) |
#define stringprep_plain | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_plain) |
Definition at line 139 of file stringprep.h.
#define STRINGPREP_VERSION "0.6.7" |
Definition at line 34 of file stringprep.h.
#define stringprep_xmpp_nodeprep | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep) |
Definition at line 155 of file stringprep.h.
#define stringprep_xmpp_resourceprep | ( | in, | |||
maxlen | ) | stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep) |
Definition at line 157 of file stringprep.h.
typedef struct Stringprep_table Stringprep_profile |
Definition at line 93 of file stringprep.h.
typedef struct Stringprep_profiles Stringprep_profiles |
Definition at line 100 of file stringprep.h.
typedef struct Stringprep_table_element Stringprep_table_element |
Definition at line 85 of file stringprep.h.
Definition at line 57 of file stringprep.h.
STRINGPREP_NFKC | |
STRINGPREP_BIDI | |
STRINGPREP_MAP_TABLE | |
STRINGPREP_UNASSIGNED_TABLE | |
STRINGPREP_PROHIBIT_TABLE | |
STRINGPREP_BIDI_PROHIBIT_TABLE | |
STRINGPREP_BIDI_RAL_TABLE | |
STRINGPREP_BIDI_L_TABLE |
Definition at line 65 of file stringprep.h.
enum Stringprep_rc |
Definition at line 37 of file stringprep.h.
int stringprep | ( | char * | in, | |
size_t | maxlen, | |||
Stringprep_profile_flags | flags, | |||
const Stringprep_profile * | profile | |||
) |
stringprep - prepare internationalized string
in | input/ouput array with string to prepare. | |
maxlen | maximum length of input/output array. | |
flags | a Stringprep_profile_flags value, or 0. | |
profile | pointer to Stringprep_profile to use. |
Note that you must convert strings entered in the systems locale into UTF-8 before using this function, see stringprep_locale_to_utf8().
Since the stringprep operation can expand the string, indicate how large the buffer holding the string is. This function will not read or write to characters outside that size.
The are one of Stringprep_profile_flags values, or 0.
The contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.
Return value: Returns STRINGPREP_OK iff successful, or an error code.
Definition at line 359 of file stringprep.c.
References stringprep_4i(), STRINGPREP_MALLOC_ERROR, STRINGPREP_OK, STRINGPREP_TOO_SMALL_BUFFER, stringprep_ucs4_to_utf8(), stringprep_utf8_to_ucs4(), and uint32_t.
Referenced by stringprep_profile().
int stringprep_4i | ( | uint32_t * | ucs4, | |
size_t * | len, | |||
size_t | maxucs4len, | |||
Stringprep_profile_flags | flags, | |||
const Stringprep_profile * | profile | |||
) |
stringprep_4i - prepare internationalized string
ucs4 | input/output array with string to prepare. | |
len | on input, length of input array with Unicode code points, on exit, length of output array with Unicode code points. | |
maxucs4len | maximum length of input/output array. | |
flags | a Stringprep_profile_flags value, or 0. | |
profile | pointer to Stringprep_profile to use. |
The input is not required to be zero terminated ([] = 0). The output will not be zero terminated unless [] = 0. Instead, see stringprep_4zi() if your input is zero terminated or if you want the output to be.
Since the stringprep operation can expand the string, indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.
The are one of Stringprep_profile_flags values, or 0.
The contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.
Return value: Returns STRINGPREP_OK iff successful, or an Stringprep_rc error code.
Definition at line 138 of file stringprep.c.
References Stringprep_table::operation, STRINGPREP_BIDI, STRINGPREP_BIDI_BOTH_L_AND_RAL, STRINGPREP_BIDI_CONTAINS_PROHIBITED, STRINGPREP_BIDI_L_TABLE, STRINGPREP_BIDI_LEADTRAIL_NOT_RAL, STRINGPREP_BIDI_PROHIBIT_TABLE, STRINGPREP_BIDI_RAL_TABLE, STRINGPREP_CONTAINS_PROHIBITED, STRINGPREP_CONTAINS_UNASSIGNED, STRINGPREP_FLAG_ERROR, STRINGPREP_MAP_TABLE, STRINGPREP_NFKC, STRINGPREP_NFKC_FAILED, STRINGPREP_NO_NFKC, STRINGPREP_NO_UNASSIGNED, STRINGPREP_OK, STRINGPREP_PROFILE_ERROR, STRINGPREP_PROHIBIT_TABLE, STRINGPREP_TOO_SMALL_BUFFER, stringprep_ucs4_nfkc_normalize(), STRINGPREP_UNASSIGNED_TABLE, uint32_t, and UNAPPLICAPLEFLAGS.
Referenced by stringprep().
int stringprep_4zi | ( | uint32_t * | ucs4, | |
size_t | maxucs4len, | |||
Stringprep_profile_flags | flags, | |||
const Stringprep_profile * | profile | |||
) |
stringprep_4zi - prepare internationalized string
ucs4 | input/output array with zero terminated string to prepare. | |
maxucs4len | maximum length of input/output array. | |
flags | a Stringprep_profile_flags value, or 0. | |
profile | pointer to Stringprep_profile to use. |
Since the stringprep operation can expand the string, indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.
The are one of Stringprep_profile_flags values, or 0.
The contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.
Return value: Returns STRINGPREP_OK iff successful, or an Stringprep_rc error code.
Definition at line 319 of file stringprep.c.
const char* stringprep_check_version | ( | const char * | req_version | ) |
stringprep_check_version - check for library version
req_version | Required version number, or NULL. |
See STRINGPREP_VERSION for a suitable string.
Return value: Version string of run-time library, or NULL if the run-time library does not meet the required version number.
char* stringprep_convert | ( | const char * | str, | |
const char * | to_codeset, | |||
const char * | from_codeset | |||
) |
stringprep_convert - encode string using new character set
str | input zero-terminated string. | |
to_codeset | name of destination character set. | |
from_codeset | name of origin character set, as used by . |
Return value: Returns newly allocated zero-terminated string which is transcoded into to_codeset.
Definition at line 110 of file toutf8.c.
References iconv_string().
Referenced by stringprep_locale_to_utf8(), and stringprep_utf8_to_locale().
const char* stringprep_locale_charset | ( | void | ) |
stringprep_locale_charset - return charset used in current locale
Find out current locale charset. The function respect the CHARSET environment variable, but typically uses nl_langinfo(CODESET) when it is supported. It fall back on "ASCII" if CHARSET isn't set and nl_langinfo isn't supported or return anything.
Note that this function return the application's locale's preferred charset (or thread's locale's preffered charset, if your system support thread-specific locales). It does not return what the system may be using. Thus, if you receive data from external sources you cannot in general use this function to guess what charset it is encoded in. Use stringprep_convert from the external representation into the charset returned by this function, to have data in the locale encoding.
Return value: Return the character set used by the current locale. It will never return NULL, but use "ASCII" as a fallback.
Definition at line 79 of file toutf8.c.
Referenced by stringprep_locale_to_utf8(), and stringprep_utf8_to_locale().
char* stringprep_locale_to_utf8 | ( | const char * | str | ) |
stringprep_locale_to_utf8 - convert locale encoded string to UTF-8
str | input zero terminated string. |
Return value: Returns newly allocated zero-terminated string which is transcoded into UTF-8.
Definition at line 137 of file toutf8.c.
References stringprep_convert(), and stringprep_locale_charset().
Referenced by idna_to_ascii_lz(), idna_to_unicode_lzlz(), and tld_check_lz().
int stringprep_profile | ( | const char * | in, | |
char ** | out, | |||
const char * | profile, | |||
Stringprep_profile_flags | flags | |||
) |
stringprep_profile - prepare internationalized string
in | input array with UTF-8 string to prepare. | |
out | output variable with pointer to newly allocate string. | |
profile | name of stringprep profile to use. | |
flags | a Stringprep_profile_flags value, or 0. |
Note that you must convert strings entered in the systems locale into UTF-8 before using this function, see stringprep_locale_to_utf8().
The output variable must be deallocated by the caller.
The are one of Stringprep_profile_flags values, or 0.
The specifies the name of the stringprep profile to use. It must be one of the internally supported stringprep profiles.
Return value: Returns STRINGPREP_OK iff successful, or an error code.
Definition at line 438 of file stringprep.c.
References Stringprep_profiles::name, stringprep(), STRINGPREP_MALLOC_ERROR, stringprep_profiles, STRINGPREP_UNKNOWN_PROFILE, and Stringprep_profiles::tables.
const char* stringprep_strerror | ( | Stringprep_rc | rc | ) |
stringprep_strerror - return string describing stringprep error code
rc | a Stringprep_rc return code. |
STRINGPREP_OK: Successful operation. This value is guaranteed to always be zero, the remaining ones are only guaranteed to hold non-zero values, for logical comparison purposes. STRINGPREP_CONTAINS_UNASSIGNED: String contain unassigned Unicode code points, which is forbidden by the profile. STRINGPREP_CONTAINS_PROHIBITED: String contain code points prohibited by the profile. STRINGPREP_BIDI_BOTH_L_AND_RAL: String contain code points with conflicting bidirection category. STRINGPREP_BIDI_LEADTRAIL_NOT_RAL: Leading and trailing character in string not of proper bidirectional category. STRINGPREP_BIDI_CONTAINS_PROHIBITED: Contains prohibited code points detected by bidirectional code. STRINGPREP_TOO_SMALL_BUFFER: Buffer handed to function was too small. This usually indicate a problem in the calling application. STRINGPREP_PROFILE_ERROR: The stringprep profile was inconsistent. This usually indicate an internal error in the library. STRINGPREP_FLAG_ERROR: The supplied flag conflicted with profile. This usually indicate a problem in the calling application. STRINGPREP_UNKNOWN_PROFILE: The supplied profile name was not known to the library. STRINGPREP_NFKC_FAILED: The Unicode NFKC operation failed. This usually indicate an internal error in the library. STRINGPREP_MALLOC_ERROR: The malloc() was out of memory. This is usually a fatal error.
Return value: Returns a pointer to a statically allocated string containing a description of the error with the return code .
Definition at line 69 of file strerror-stringprep.c.
References _, STRINGPREP_BIDI_BOTH_L_AND_RAL, STRINGPREP_BIDI_CONTAINS_PROHIBITED, STRINGPREP_BIDI_LEADTRAIL_NOT_RAL, STRINGPREP_CONTAINS_PROHIBITED, STRINGPREP_CONTAINS_UNASSIGNED, STRINGPREP_FLAG_ERROR, STRINGPREP_MALLOC_ERROR, STRINGPREP_NFKC_FAILED, STRINGPREP_OK, STRINGPREP_PROFILE_ERROR, STRINGPREP_TOO_SMALL_BUFFER, and STRINGPREP_UNKNOWN_PROFILE.
uint32_t* stringprep_ucs4_nfkc_normalize | ( | uint32_t * | str, | |
ssize_t | len | |||
) |
stringprep_ucs4_nfkc_normalize - normalize Unicode string
str | a Unicode string. | |
len | length of array, or -1 if is nul-terminated. |
Return value: a newly allocated Unicode string, that is the NFKC normalized form of .
Definition at line 1048 of file nfkc.c.
References G_NORMALIZE_NFKC, stringprep_ucs4_to_utf8(), and uint32_t.
Referenced by stringprep_4i().
char* stringprep_ucs4_to_utf8 | ( | const uint32_t * | str, | |
ssize_t | len, | |||
size_t * | items_read, | |||
size_t * | items_written | |||
) |
stringprep_ucs4_to_utf8 - convert UCS-4 string to UTF-8
str | a UCS-4 encoded string | |
len | the maximum length of to use. If < 0, then the string is terminated with a 0 character. | |
items_read | location to store number of characters read read, or NULL. | |
items_written | location to store number of bytes written or NULL. The value here stored does not include the trailing 0 byte. |
Return value: a pointer to a newly allocated UTF-8 string. This value must be freed with free(). If an error occurs, NULL will be returned and set.
Definition at line 1001 of file nfkc.c.
References glong.
Referenced by idna_to_ascii_4i(), idna_to_unicode_44i(), idna_to_unicode_8z8z(), stringprep(), and stringprep_ucs4_nfkc_normalize().
int stringprep_unichar_to_utf8 | ( | uint32_t | c, | |
char * | outbuf | |||
) |
stringprep_unichar_to_utf8 - convert Unicode code point to UTF-8
c | a ISO10646 character code | |
outbuf | output buffer, must have at least 6 bytes of space. If NULL, the length will be computed and returned and nothing will be written to . |
Return value: number of bytes written.
char* stringprep_utf8_nfkc_normalize | ( | const char * | str, | |
ssize_t | len | |||
) |
stringprep_utf8_nfkc_normalize - normalize Unicode string
str | a UTF-8 encoded string. | |
len | length of , in bytes, or -1 if is nul-terminated. |
The normalization mode is NFKC (ALL COMPOSE). It standardizes differences that do not affect the text content, such as the above-mentioned accent representation. It 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. It returns a result with composed forms rather than a maximally decomposed form.
Return value: a newly allocated string, that is the NFKC normalized form of .
Definition at line 1031 of file nfkc.c.
References G_NORMALIZE_NFKC.
char* stringprep_utf8_to_locale | ( | const char * | str | ) |
stringprep_utf8_to_locale - encode UTF-8 string to locale encoding
str | input zero terminated string. |
Return value: Returns newly allocated zero-terminated string which is transcoded into the locale's character set.
Definition at line 153 of file toutf8.c.
References stringprep_convert(), and stringprep_locale_charset().
Referenced by idna_to_unicode_8zlz().
uint32_t* stringprep_utf8_to_ucs4 | ( | const char * | str, | |
ssize_t | len, | |||
size_t * | items_written | |||
) |
stringprep_utf8_to_ucs4 - convert UTF-8 string to UCS-4
str | a UTF-8 encoded string | |
len | the maximum length of to use. If < 0, then the string is nul-terminated. | |
items_written | location to store the number of characters in the result, or NULL. |
Return value: a pointer to a newly allocated UCS-4 string. This value must be freed with free().
Definition at line 977 of file nfkc.c.
References glong.
Referenced by idna_to_ascii_4i(), idna_to_ascii_8z(), idna_to_unicode_8z4z(), pr29_8z(), stringprep(), and tld_check_8z().
uint32_t stringprep_utf8_to_unichar | ( | const char * | p | ) |
stringprep_utf8_to_unichar - convert UTF-8 to Unicode code point
p | a pointer to Unicode character encoded as UTF-8 |
does
not point to a valid UTF-8 encoded character, results are undefined.Return value: the resulting character.
const Stringprep_profile stringprep_iscsi[] |
Definition at line 246 of file profiles.c.
Definition at line 60 of file profiles.c.
Definition at line 37 of file profiles.c.
const Stringprep_profile stringprep_plain[] |
Definition at line 144 of file profiles.c.
Definition at line 292 of file profiles.c.
const Stringprep_profile stringprep_trace[] |
Definition at line 160 of file profiles.c.
Definition at line 97 of file profiles.c.
Definition at line 85 of file profiles.c.
Definition at line 122 of file profiles.c.