Skip Navigation Links | |
Exit Print View | |
man pages section 9: DDI and DKI Kernel Functions Oracle Solaris 11.1 Information Library |
csx_AccessConfigurationRegister(9F)
csx_Parse_CISTPL_BYTEORDER(9F)
csx_Parse_CISTPL_CFTABLE_ENTRY(9F)
csx_Parse_CISTPL_DEVICEGEO(9F)
csx_Parse_CISTPL_DEVICEGEO_A(9F)
csx_Parse_CISTPL_DEVICE_OA(9F)
csx_Parse_CISTPL_DEVICE_OC(9F)
csx_Parse_CISTPL_LINKTARGET(9F)
csx_Parse_CISTPL_LONGLINK_A(9F)
csx_Parse_CISTPL_LONGLINK_C(9F)
csx_Parse_CISTPL_LONGLINK_MFC(9F)
ddi_get_soft_iblock_cookie(9F)
ddi_intr_get_supported_types(9F)
ddi_prop_lookup_byte_array(9F)
ddi_prop_lookup_int64_array(9F)
ddi_prop_lookup_string_array(9F)
ddi_prop_update_byte_array(9F)
ddi_prop_update_int64_array(9F)
ddi_prop_update_string_array(9F)
ldi_prop_lookup_byte_array(9F)
ldi_prop_lookup_int64_array(9F)
ldi_prop_lookup_string_array(9F)
mac_prop_info_set_default_link_flowctrl(9F)
mac_prop_info_set_default_str(9F)
mac_prop_info_set_default_uint8(9F)
mac_prop_info_set_range_uint32(9F)
net_event_notify_unregister(9F)
net_instance_notify_register(9F)
net_instance_notify_unregister(9F)
net_instance_protocol_unregister(9F)
net_protocol_notify_register(9F)
nvlist_lookup_boolean_array(9F)
nvlist_lookup_boolean_value(9F)
nvlist_lookup_nvlist_array(9F)
nvlist_lookup_string_array(9F)
nvlist_lookup_uint16_array(9F)
nvlist_lookup_uint32_array(9F)
nvlist_lookup_uint64_array(9F)
nvpair_value_boolean_array(9F)
pci_plist_lookup_int16_array(9F)
pci_plist_lookup_int32_array(9F)
pci_plist_lookup_int64_array(9F)
pci_plist_lookup_int8_array(9F)
pci_plist_lookup_string_array(9F)
pci_plist_lookup_uint16_array(9F)
pci_plist_lookup_uint32_array(9F)
pci_plist_lookup_uint64_array(9F)
pci_plist_lookup_uint8_array(9F)
scsi_get_device_type_scsi_options(9F)
scsi_get_device_type_string(9F)
scsi_sense_cmdspecific_uint64(9F)
usb_get_current_frame_number(9F)
usb_get_max_pkts_per_isoc_request(9F)
usb_pipe_get_max_bulk_transfer_size(9F)
usb_pipe_stop_intr_polling(9F)
usb_pipe_stop_isoc_polling(9F)
- buffer-based code conversion function
#include <sys/types.h> #include <sys/errno.h> #include <sys/sunddi.h> size_t kiconv(kiconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, int *errno);
Solaris DDI specific (Solaris DDI).
The parameters for the kiconv function are as follows:
Code conversion descriptor indicating the code conversion and conversion state.
Points to an address of a buffer containing a sequence of character bytes in fromcode codeset to be converted. After the conversion, the variable is updated to point to the byte following the last byte that was successfully used in the conversion.
As an input parameter, the number of bytes to be converted in inbuf. As an output parameter, the number of bytes in inbuf still not converted after the conversion.
Points to an address of a buffer where converted character bytes in tocode codeset can be saved. After the conversion, the variable is updated to point to the byte following the last byte of converted output data.
As an input parameter, the number of available bytes at outbuf where converted character bytes can be saved. As an output parameter, the number of bytes still available at outbuf after the conversion.
Indicates the error when conversion is not completed or failed. The following are possible values:
The input conversion was stopped due to an input byte that does not belong to the input codeset.
The input conversion was stopped due to lack of space in the output buffer.
The input conversion was stopped due to an incomplete character or shift sequence at the end of the input buffer.
The cd input parameter is not a valid open code conversion descriptor.
The kiconv() function converts the sequence of characters from one codeset, in the array specified by inbuf, into a sequence of corresponding characters in another codeset, in the array specified by outbuf. The codesets are those specified in the kiconv_open() call that returned the code conversion descriptor, cd. The inbuf parameter points to a variable that points to the first character in the input buffer and inbytesleft indicates the number of bytes to the end of the buffer to be converted. The outbuf parameter points to a variable that points to the first available byte in the output buffer and outbytesleft indicates the number of the available bytes to the end of the buffer.
For state-dependent encodings, the conversion descriptor cd is placed into its initial shift state by a call for which inbuf is a null pointer, or for which inbuf points to a null pointer. When kiconv() is called in this way, and if outbuf is not a null pointer or a pointer to a null pointer, and outbytesleft points to a positive value, kiconv() places, if any, into the output buffer, the byte sequence to change the output buffer to its initial shift state. If the output buffer is not large enough to hold the entire reset sequence, kiconv() fails and sets errno to E2BIG. Subsequent calls with inbuf as other than a null pointer or a pointer to a null pointer cause the conversion to take place from the current state of the conversion descriptor.
If a sequence of input bytes does not form a valid character in the specified codeset, conversion stops after the previous successfully converted character. If the input buffer ends with an incomplete character or shift sequence, conversion stops after the previous successfully converted bytes. If the output buffer is not large enough to hold the entire converted input, conversion stops just prior to the input bytes that would cause the output buffer to overflow. The variable pointed to by inbuf is updated to point to the byte following the last byte that was successfully used in the conversion. The value pointed to by inbytesleft is decremented to reflect the number of bytes still not converted in the input buffer. The variable pointed to by outbuf is updated to point to the byte following the last byte of converted output data. The value pointed to by outbytesleft is decremented to reflect the number of bytes still available in the output buffer. For state-dependent encodings, the conversion descriptor is updated to reflect the shift state in effect at the end of the last successfully converted byte sequence.
If kiconv() encounters a character in the input buffer that is legal, but for which an identical character does not exist in the target codeset, kiconv() performs an implementation-defined conversion (that is, a non-identical conversion) on this character.
The kiconv() function updates the variables pointed to by the parameters to reflect the extent of the conversion and returns the number of non-identical conversions performed. If the entire string in the input buffer is converted, the value pointed to by inbytesleft is 0. If the input conversion is stopped due to any conditions mentioned above, the value pointed to by inbytesleft is non-zero and errno is set to indicate the condition. If such and other error occurs, kiconv() returns (size_t)-1 and sets errno to indicate the error.
kiconv() can be called from user or interrupt context.
Example 1 Performing a Simple Conversion
The following example shows how to perform a simple conversion using kiconv() with a limited size of output buffer:
#include <sys/types.h> #include <sys/errno.h> #include <sys/sunddi.h> int doconversion(char *fromcode, char *tocode, char *inbuf, char *outbuf, size_t inlen, size_t *outlen) { kiconv_t cd; size_t ileft, ret; int err; cd = kiconv_open((const char *)tocode, (const char *)fromcode); if (cd == (kiconv_t)-1) { /* Cannot open conversion. */ return (-1); } ret = kiconv(cd, &inbuf, &inlen, &outbuf, outlen, &err); if (ret == (size_t)-1) goto doconv_error_return; /* * Reset the conversion descriptor. This will also * make sure to write to output buffer any saved bytes * in the conversion descriptor state. */ ileft = 0; ret = kiconv(cd, (char *)NULL, &ileft, &outbuf, outlen, &err); if (ret == (size_t)-1) goto doconv_error_return; (void) kiconv_close(cd); return (0); doconv_error_return: (void) kiconv_close(cd); /* Need more output buffer. */ if (err == E2BIG) return (-2); /* Illegal sequence? */ if (err == EILSEQ) return (-3); /* Incomplete character? */ if (err == EINVAL) return (-4); /* * Bad code conversion descriptor or any other unknown error. */ return (-5); }
See attributes(5) for descriptions of the following attributes:
|
iconv(3C), iconv_close(3C), iconv_open(3C), u8_strcmp(3C), u8_textprep_str(3C), u8_validate(3C), uconv_u16tou32(3C), uconv_u16tou8(3C), uconv_u32tou16(3C), uconv_u32tou8(3C), uconv_u8tou16(3C), uconv_u8tou32(3C), attributes(5), kiconvstr(9F), kiconv_close(9F), kiconv_open(9F), u8_strcmp(9F), u8_textprep_str(9F), u8_validate(9F), uconv_u16tou32(9F), uconv_u16tou8(9F), uconv_u32tou16(9F), uconv_u32tou8(9F), uconv_u8tou16(9F), uconv_u8tou32(9F)
The Unicode Standard:
http://www.unicode.org/standard/standard.html
The iconv(3C) man page also has a good example code that can be referenced.