.\" Copyright (c) 1999 G. Adam Stanislav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" libutf-8 v.1 .\" .Dd April 1, 1999 .Dt SPUTU8 3 .Os .Sh NAME .Nm sputu8 .Nd utf-8 library function manual page .Sh SYNOPSIS .Fd #include .Ft char * .Fn sputu8 "unsigned int c" "char *buffer" .Ft char * .Fn utf8sputc "unsigned int c" "char *buffer" .Sh DESCRIPTION The .Fn sputu8 function of utf-8 library converts a UTC-4 (31-bit Unicode) integer to a sequence of one or more characters representing its UTF-8 value, and writes the result to a buffer (character string). It appends a NUL at the end of the buffer, so it can be processed as a standard C string. .Pp .Fn utf8sputc is a macro which simply gives .Fn sputu8 a name that may be more convenient to remember. It is defined in .Aq Pa utf-8.h . .Pp The .Fn sputu8 function and the .Fn utf8sputc macro take two arguments: .Fa c , the UTC-4 code, and .Fa buffer , a pointer to a string of characters. The buffer must have at least seven bytes available for writing: UTF-8 encodes Unicode into 1 - 6 characters, plus we need room for the terminating NUL. .Sh RETURN VALUES .Fn sputu8 returns the pointer to the terminating NUL. This allows you to append the next sequence of characters without having to determine where the string ends after each call to .Fn sputu8 . .Pp If .Fa buffer is NULL, .Fn sputu8 returns NULL. If .Fa c is not a valid UTC-4 code (i.e., its high bit is set), no conversion takes place, and .Fn sputu8 just returns .Fa buffer . .Sh SEE ALSO .Xr libutf-8 3 , .Xr fgetu8 3 , .Xr fputu8 , .Xr sgetu8 3 .Rs .%A F. Yergeau .%T UTF-8, a transformation format of Unicode and ISO 10646 .%O RFC2044 .Re .Rs .%A D. Goldsmith, M. Davis .%T Using Unicode with MIME .%O RFC1641 .Re .Sh STANDARDS ISO 10646-1: 1993 (``Unicode''), RFC 2044: 1996 (``UTF-8''), .St -ansiC . .Sh DIAGNOSTICS You should always compare the .Sx RETURN VALUES to .Fa buffer . If they are NULL, no conversion took place. Otherwise, if they are identical, .Fa c was not a valid UTC-8 integer. Anything else indicates successful conversion. .Sh AUTHORS This manual page was written by .An G. Adam Stanislav Aq adam@whizkidtech.net . .Sh BUGS None known.