Next: Punycode Functions, Previous: Utility Functions, Up: GNU Libidn [Contents][Index]
Stringprep describes a framework for preparing Unicode text strings in order to increase the likelihood that string input and string comparison work in ways that make sense for typical users throughout the world. The stringprep protocol is useful for protocol identifier values, company and personal names, internationalized domain names, and other text strings.
stringprep.h
stringprep.h
To use the functions explained in this chapter, you need to include the file stringprep.h using:
#include <stringprep.h>
Further types and structures are defined for applications that want to specify their own stringprep profile. As these are fairly obscure, and by necessity tied to the implementation, we do not document them here. Look into the stringprep.h header file, and the profiles.c source code for the details.
Disable the NFKC normalization, as well as selecting the non-NFKC case folding tables. Usually the profile specifies BIDI and NFKC settings, and applications should not override it unless in special situations.
Disable the BIDI step. Usually the profile specifies BIDI and NFKC settings, and applications should not override it unless in special situations.
Make the library return with an error if string contains unassigned characters according to profile.
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.
Prepare the input UCS-4 string according to the stringprep profile, and write back the result to the input string.
The input is not required to be zero terminated ( ucs4
[ len
] = 0).
The output will not be zero terminated unless ucs4
[ len
] = 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, maxucs4len
indicate how large the buffer holding the string is. This function
will not read or write to code points outside that size.
The flags
are one of Stringprep_profile_flags
values, or 0.
The profile
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.
Prepare the input UCS-4 string according to the stringprep profile,
and write back the result to the input string.
The input is not required to be zero terminated ( ucs4
[ len
] = 0).
The output will not be zero terminated unless ucs4
[ len
] = 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, maxucs4len
indicate how large the buffer holding the string is. This function
will not read or write to code points outside that size.
The flags
are one of Stringprep_profile_flags
values, or 0.
The profile
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.
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.
Prepare the input zero terminated UCS-4 string according to the stringprep profile, and write back the result to the input string.
Since the stringprep operation can expand the string, maxucs4len
indicate how large the buffer holding the string is. This function
will not read or write to code points outside that size.
The flags
are one of Stringprep_profile_flags
values, or 0.
The profile
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.
in: input/output 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.
Prepare the input zero terminated UTF-8 string according to the stringprep profile, and write back the result to the input string.
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, maxlen
indicate how large the buffer holding the string is. This function
will not read or write to characters outside that size.
The flags
are one of Stringprep_profile_flags
values, or 0.
The profile
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.
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.
Prepare the input zero terminated UTF-8 string according to the stringprep profile, and return the result in a newly allocated variable.
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 out
variable must be deallocated by the caller.
The flags
are one of Stringprep_profile_flags
values, or 0.
The profile
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.
rc: a Stringprep_rc
return code.
Convert a return code integer to a text string. This string can be used to output a diagnostic message to the user.
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_ICONV_ERROR: Character encoding conversion error.
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 rc
.
in: input/output array with string to prepare.
maxlen: maximum length of input/output array.
Prepare the input UTF-8 string according to the nameprep profile. The
AllowUnassigned flag is false, use stringprep_nameprep
for
true AllowUnassigned. Returns 0 iff successful, or an error code.
in: input/output array with string to prepare.
maxlen: maximum length of input/output array.
Prepare the input UTF-8 string according to the draft iSCSI stringprep profile. Returns 0 iff successful, or an error code.
in: input/output array with string to prepare.
maxlen: maximum length of input/output array.
Prepare the input UTF-8 string according to the draft SASL ANONYMOUS profile. Returns 0 iff successful, or an error code.
in: input/output array with string to prepare.
maxlen: maximum length of input/output array.
Prepare the input UTF-8 string according to the draft XMPP node identifier profile. Returns 0 iff successful, or an error code.
in: input/output array with string to prepare.
maxlen: maximum length of input/output array.
Prepare the input UTF-8 string according to the draft XMPP resource identifier profile. Returns 0 iff successful, or an error code.
Next: Punycode Functions, Previous: Utility Functions, Up: GNU Libidn [Contents][Index]