Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/man/man3c/./u8_validate.3c
Real path: /usr/share/man/man3c/u8_validate.3c
Zurück
'\" te .\" Copyright (c) 2007, 2020, Oracle and/or its affiliates. .TH u8_validate 3C "18 Sep 2007" "Oracle Solaris 11.4" "Standard C Library Functions" .SH NAME u8_validate \- validate UTF-8 characters and calculate the byte length .SH SYNOPSIS .LP .nf #include <sys/u8_textprep.h> \fBint\fR u8_validate(\fBchar *\fR\fIu8str\fR, \fBsize_t\fR \fIn\fR, \fBchar **\fR\fIlist\fR, \fBint\fR \fIflag\fR, \fBint *\fR\fIerrnum\fR); .fi .SH PARAMETERS .sp .ne 2 .mk .na \fB\fIu8str\fR\fR .ad .RS 10n .rt The UTF-8 string to be validated. .RE .sp .ne 2 .mk .na \fB\fIn\fR\fR .ad .RS 10n .rt The maximum number of bytes in \fIu8str\fR that can be examined and validated. .RE .sp .ne 2 .mk .na \fB\fIlist\fR\fR .ad .RS 10n .rt A list of null-terminated character strings in UTF-8 that must be additionally checked against as invalid characters. The last string in \fIlist\fR must be null to indicate there is no further string. .RE .sp .ne 2 .mk .na \fB\fIflag\fR\fR .ad .RS 10n .rt Possible validation options constructed by a bitwise-inclusive-OR of the following values: .sp .ne 2 .mk .na \fB\fBU8_VALIDATE_ENTIRE\fR\fR .ad .br .sp .6 .RS 4n By default, \fBu8_validate()\fR looks at the first character or up to \fIn\fR bytes, whichever is smaller in terms of the number of bytes to be consumed, and returns with the result. .sp When this option is used, \fBu8_validate()\fR will check up to \fIn\fR bytes from \fIu8str\fR and possibly more than a character before returning the result. .RE .sp .ne 2 .mk .na \fB\fBU8_VALIDATE_CHECK_ADDITIONAL\fR\fR .ad .br .sp .6 .RS 4n By default, \fBu8_validate()\fR does not use list supplied. .sp When this option is supplied with a list of character strings, \fBu8_validate()\fR additionally validates \fIu8str\fR against the character strings supplied with \fIlist\fR and returns EBADF in \fIerrnum\fR if \fIu8str\fR has any one of the character strings in \fIlist\fR. .RE .sp .ne 2 .mk .na \fB\fBU8_VALIDATE_UCS2_RANGE\fR\fR .ad .br .sp .6 .RS 4n By default, \fBu8_validate()\fR uses the entire Unicode coding space of U+0000 to U+10FFFF. .sp When this option is specified, the valid Unicode coding space is smaller to U+0000 to U+FFFF. .RE .RE .sp .ne 2 .mk .na \fB\fIerrnum\fR\fR .ad .RS 10n .rt An error occurred during validation. The following values are supported: .sp .ne 2 .mk .na \fB\fBEBADF\fR\fR .ad .RS 10n .rt Validation failed because list-specified characters were found in the string pointed to by \fIu8str\fR. .RE .sp .ne 2 .mk .na \fB\fBEILSEQ\fR\fR .ad .RS 10n .rt Validation failed because an illegal byte was found in the string pointed to by \fIu8str\fR. .RE .sp .ne 2 .mk .na \fB\fBEINVAL\fR\fR .ad .RS 10n .rt Validation failed because an incomplete byte was found in the string pointed to by \fIu8str\fR. .RE .sp .ne 2 .mk .na \fB\fBERANGE\fR\fR .ad .RS 10n .rt Validation failed because character bytes were encountered that are outside the range of the Unicode coding space. .RE .RE .SH DESCRIPTION .sp .LP The \fBu8_validate()\fR function validates \fIu8str\fR in UTF-8 and determines the number of bytes constituting the character(s) pointed to by \fIu8str\fR. .SH RETURN VALUES .sp .LP If \fIu8str\fR is a null pointer, \fBu8_validate()\fR returns 0. Otherwise, \fBu8_validate()\fR returns either the number of bytes that constitute the characters if the next \fIn\fR or fewer bytes form valid characters, or -1 if there is an validation failure, in which case it may set \fIerrnum\fR to indicate the error. .SH EXAMPLES .LP \fBExample 1\fR Determine the length of the first UTF-8 character. .sp .in +2 .nf #include <sys/u8_textprep.h> char u8[MAXPATHLEN]; int errnum; \&. \&. \&. len = u8_validate(u8, 4, (char **)NULL, 0, &errnum); if (len == -1) { switch (errnum) { case EILSEQ: case EINVAL: return (MYFS4_ERR_INVAL); case EBADF: return (MYFS4_ERR_BADNAME); case ERANGE: return (MYFS4_ERR_BADCHAR); default: return (-10); } } .fi .in -2 .sp .LP \fBExample 2\fR Check if there are any invalid characters in the entire string. .sp .in +2 .nf #include <sys/u8_textprep.h> char u8[MAXPATHLEN]; int n; int errnum; \&. \&. \&. n = strlen(u8); len = u8_validate(u8, n, (char **)NULL, U8_VALIDATE_ENTIRE, &errnum); if (len == -1) { switch (errnum) { case EILSEQ: case EINVAL: return (MYFS4_ERR_INVAL); case EBADF: return (MYFS4_ERR_BADNAME); case ERANGE: return (MYFS4_ERR_BADCHAR); default: return (-10); } } .fi .in -2 .sp .LP \fBExample 3\fR Check if there is any invalid character, including prohibited characters, in the entire string. .sp .in +2 .nf #include <sys/u8_textprep.h> char u8[MAXPATHLEN]; int n; int errnum; char *prohibited[4] = { ".", "..", "\e\e", NULL }; \&. \&. \&. n = strlen(u8); len = u8_validate(u8, n, prohibited, (U8_VALIDATE_ENTIRE|U8_VALIDATE_CHECK_ADDITIONAL), &errnum); if (len == -1) { switch (errnum) { case EILSEQ: case EINVAL: return (MYFS4_ERR_INVAL); case EBADF: return (MYFS4_ERR_BADNAME); case ERANGE: return (MYFS4_ERR_BADCHAR); default: return (-10); } } .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level MT-Safe .TE .sp .SH SEE ALSO .sp .LP \fBu8_strcmp\fR(3C), \fBu8_textprep_str\fR(3C), \fBattributes\fR(7), \fBu8_strcmp\fR(9F), \fBu8_textprep_str\fR(9F), \fBu8_validate\fR(9F) .sp .LP The Unicode Standard (https://www.unicode.org/standard/standard.html)