.\" Copyright (C) 2001 Information-technology Promotion Agency (IPA) .\" Copyright (C) 2001-2003 .\" National Institute of Advanced Industrial Science and Technology (AIST) .\" This file si aprt of the m17n library documentation. .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.2 or .\" any later version published by the Free Software Foundation; with no .\" Invariant Section, Front-Cover Texts "The m17n library documentation", .\" and no Back-Cover Texts. A copy of the license is included in the .\" appendix entitled "GNU Free Documentation License". .TH "mtext_from_data" 3m17n "14 Jul 2007" "" "Version 1.4.0" "" "The m17n Library" \" -*- nroff -*- .ad l .nh .SH NAME mtext_from_data - Allocate a new M-text with specified data. .SH SYNOPSIS \fBMText\fP* \fBmtext_from_data\fP (const void * \fIdata\fP, int \fInitems\fP, enum \fBMTextFormat\fP \fIformat\fP) .SH DESCRIPTION The .ft B mtext_from_data() .ft R function allocates a new M-text whose character sequence is specified by array .ft B data .ft R of .ft B nitems .ft R elements. .ft B format .ft R specifies the format of .ft B data\fP. .ft R .PP When .ft B format .ft R is either .ft B MTEXT_FORMAT_US_ASCII .ft R or .ft B MTEXT_FORMAT_UTF_8\fP, .ft R the contents of .ft B data .ft R must be of the type .ft C unsigned .ft R .ft C char\fP, .ft R and .ft B nitems .ft R counts by byte. .PP When .ft B format .ft R is either .ft B MTEXT_FORMAT_UTF_16LE .ft R or .ft B MTEXT_FORMAT_UTF_16BE\fP, .ft R the contents of .ft B data .ft R must be of the type .ft C unsigned .ft R .ft C short\fP, .ft R and .ft B nitems .ft R counts by unsigned short. .PP When .ft B format .ft R is either .ft B MTEXT_FORMAT_UTF_32LE .ft R or .ft B MTEXT_FORMAT_UTF_32BE\fP, .ft R the contents of .ft B data .ft R must be of the type .ft C unsigned\fP, .ft R and .ft B nitems .ft R counts by unsigned. .PP The character sequence of the M-text is not modifiable. The contents of .ft B data .ft R must not be modified while the M-text is alive. .PP The allocated M-text will not be freed unless the user explicitly does so with the .ft B m17n_object_unref() .ft R function. Even in that case, .ft B data .ft R is not freed. .PP .SH RETURN VALUE .PP.RS 4 If the operation was successful, .ft B mtext_from_data() .ft R returns a pointer to the allocated M-text. Otherwise it returns .ft C NULL .ft R and assigns an error code to the external variable .ft B merror_code\fP. .ft R .RE .PP .SH ERRORS .PP.RS 4 \fCMERROR_MTEXT .ft R .RE .PP