| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- Unicode encoding conversion functions
#include <sys/types.h>#include <sys/errno.h>#include <sys/u8_textprep.h>intuconv_u16tou32(constuint16_t *utf16str,size_t *utf16len,uint32_t *utf32str,size_t *utf32len,intflag);
intuconv_u16tou8(constuint16_t *utf16str,size_t *utf16len,uchar_t *utf8str,size_t *utf8len,intflag);
intuconv_u32tou16(constuint32_t *utf32str,size_t *utf32len,uint16_t *utf16str,size_t *utf16len,intflag);
intuconv_u32tou8(constuint32_t *utf32str,size_t *utf32len,uchar_t *utf8str,size_t *utf8len,intflag);
intuconv_u8tou16(constuchar_t *utf8str,size_t *utf8len,uint16_t *utf16str,size_t *utf16len,intflag);
intuconv_u8tou32(constuchar_t *utf8str,size_t *utf8len,uint32_t *utf32str,size_t *utf32len,intflag);
A pointer to aUTF-16 character string.
As an input parameter, the number of 16-bit unsigned integers inutf16str asUTF-16 characters to be converted or saved.
As an output parameter, the number of 16-bit unsigned integers inutf16str consumed or saved during conversion.
A pointer to aUTF-32 character string.
As an input parameter, the number of 32-bit unsigned integers inutf32str asUTF-32 characters to be converted or saved.
As an output parameter, the number of 32-bit unsigned integers inutf32str consumed or saved during conversion.
A pointer to aUTF-8 character string.
As an input parameter, the number of bytes inutf8str asUTF-8 characters to be converted or saved.
As an output parameter, the number of bytes inutf8str consumed or saved during conversion.
The possible conversion options that are constructed by a bitwise-inclusive-OR of the following values:
The input parameter is in big endian byte ordering.
The output parameter should be in big endian byte ordering.
The input parameter is in the default byte ordering of the current system.
The output parameter should be in the default byte ordering of the current system.
The input parameter is in little endian byte ordering.
The output parameter should be in little endian byte ordering.
The null orU+0000 character should not stop the conversion.
If the Byte Order Mark (BOM,U+FEFF) character exists as the first character of the input parameter, interpret it as the BOM character.
Start the output parameter with Byte Order Mark (BOM,U+FEFF) character to indicate the byte ordering if the output parameter is inUTF-16 orUTF-32.
Theuconv_u16tou32() function reads the givenutf16str inUTF-16 untilU+0000 (zero)inutf16str is encountered as a character or until the number of16-bit unsigned integers specified inutf16len is read. TheUTF-16 characters that areread are converted intoUTF-32 and the result is saved atutf32str.After the successful conversion,utf32len contains the number of 32-bit unsigned integers savedatutf32str asUTF-32 characters.
Theuconv_u16tou8() function reads the givenutf16str inUTF-16 untilU+0000 (zero)inutf16str is encountered as a character or until the number of16-bit unsigned integers specified inutf16len is read. TheUTF-16 characters thatare read are converted intoUTF-8 and the result is saved atutf8str. After the successful conversion,utf8len contains the number of bytes savedatutf8str asUTF-8 characters.
Theuconv_u32tou16() function reads the givenutf32str inUTF-32 untilU+0000 (zero)inutf32str is encountered as a character or until the number of32-bit unsigned integers specified inutf32len is read. TheUTF-32 characters that areread are converted intoUTF-16 and the result is saved atutf16str.After the successful conversion,utf16len contains the number of 16-bit unsigned integers savedatutf16str asUTF-16 characters.
Theuconv_u32tou8() function reads the givenutf32str inUTF-32 untilU+0000 (zero)inutf32str is encountered as a character or until the number of32-bit unsigned integers specified inutf32len is read. TheUTF-32 characters thatare read are converted intoUTF-8 and the result is saved atutf8str. After the successful conversion,utf8len contains the number of bytes savedatutf8str asUTF-8 characters.
Theuconv_u8tou16() function reads the givenutf8str inUTF-8 until the null('\0') byte inutf8str is encountered or until the number of bytesspecified inutf8len is read. TheUTF-8 characters that are read are convertedintoUTF-16 and the result is saved atutf16str. After the successfulconversion,utf16len contains the number of 16-bit unsigned integers saved atutf16strasUTF-16 characters.
Theuconv_u8tou32() function reads the givenutf8str inUTF-8 until the null('\0') byte inutf8str is encountered or until the number of bytesspecified inutf8len is read. TheUTF-8 characters that are read are convertedintoUTF-32 and the result is saved atutf32str. After the successfulconversion,utf32len contains the number of 32-bit unsigned integers saved atutf32strasUTF-32 characters.
During the conversion, the input and the output parameters are treated withbyte orderings specified in theflag parameter. When not specified, the defaultbyte ordering of the system is used. The byte orderingflag valuethat is specified forUTF-8 is ignored.
WhenUCONV_IN_ACCEPT_BOM is specified as theflag and the first character ofthe string pointed to by the input parameter is the BOM character,the value of the BOM character dictates the byte ordering of the subsequentcharacters in the string pointed to by the input parameter, regardless ofthe supplied input parameter byte ordering optionflag values. If theUCONV_IN_ACCEPT_BOMis not specified, the BOM as the first character is treated as aregular Unicode character: Zero Width No Break Space (ZWNBSP) character.
WhenUCONV_IGNORE_NULL is specified, regardless of whether the input parameter containsU+0000or null byte, the conversion continues until the specified number of inputparameter elements atutf16len,utf32len, orutf8len are entirely consumed during the conversion.
As output parameters,utf16len,utf32len, andutf8len are not changed if conversionfails for any reason.
Upon successful conversion, the functions return0. Upon failure, the functions returnone of the followingerrno values:
The conversion detected an illegal or out of bound character value in the input parameter.
The conversion cannot finish because the size specified in the output parameter is too small.
The conversion stops due to an incomplete character at the end of the input string.
Conflicting byte-ordering optionflag values are detected.
Example 1 Convert aUTF-16 string in little-endian byte ordering intoUTF-8 string.
#include <sys/types.h>#include <sys/errno.h>#include <sys/u8_textprep.h>...uint16_t u16s[MAXNAMELEN + 1];uchar_t u8s[MAXNAMELEN + 1];size_t u16len, u8len;int ret;...u16len = u8len = MAXNAMELEN;ret = uconv_u16tou8(u16s, &u16len, u8s, &u8len, UCONV_IN_LITTLE_ENDIAN);if (ret != 0) { /* Conversion error occurred. */ return (ret);}...Example 2 Convert aUTF-32 string in big endian byte ordering into little endianUTF-16.
#include <sys/types.h>#include <sys/errno.h>#include <sys/u8_textprep.h>.../* * An UTF-32 character can be mapped to an UTF-16 character with * two 16-bit integer entities as a "surrogate pair." */uint32_t u32s[101];uint16_t u16s[101];int ret;size_t u32len, u16len;...u32len = u16len = 100;ret = uconv_u32tou16(u32s, &u32len, u16s, &u16len, UCONV_IN_BIG_ENDIAN | UCONV_OUT_LITTLE_ENDIAN);if (ret == 0) { return (0);} else if (ret == E2BIG) { /* Use bigger output parameter and try just one more time. */ uint16_t u16s2[201]; u16len = 200; ret = uconv_u32tou16(u32s, &u32len, u16s2, &u16len, UCONV_IN_BIG_ENDIAN | UCONV_OUT_LITTLE_ENDIAN); if (ret == 0) return (0);}/* Otherwise, return -1 to indicate an error condition. */return (-1);Example 3 Convert aUTF-8 string intoUTF-16 in little-endian byte ordering.
Convert aUTF-8 string intoUTF-16 in little-endian byte ordering with aByte Order Mark (BOM) character at the beginning of the output parameter.
#include <sys/types.h>#include <sys/errno.h>#include <sys/u8_textprep>...uchar_t u8s[MAXNAMELEN + 1];uint16_t u16s[MAXNAMELEN + 1];size_t u8len, u16len;int ret;...u8len = u16len = MAXNAMELEN;ret = uconv_u8tou16(u8s, &u8len, u16s, &u16len, UCONV_IN_LITTLE_ENDIAN | UCONV_EMIT_BOM);if (ret != 0) { /* Conversion error occurred. */ return (ret);}...Seeattributes(5) for descriptions of the following attributes:
|
attributes(5),uconv_u16tou32(9F)
EachUTF-16 orUTF-32 character maps to anUTF-8 character that mightneed one to maximum of four bytes.
OneUTF-32 orUTF-8 character can yield two 16-bit unsigned integers asaUTF-16 character, which is a surrogate pair if the Unicode scalarvalue is bigger thanU+FFFF.
Ill-formedUTF-16 surrogate pairs are seen as illegal characters during the conversion.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |