.\" Copyright (C) 2001 Information-technology Promotion Agency (IPA) .\" Copyright (C) 2001-2011 .\" National Institute of Advanced Industrial Science and Technology (AIST) .\" This file is part 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, no Front-Cover Texts, .\" 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 "12 Jan 2011" "Version 1.6.2" "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 Allocate a new M\-text with specified data. 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 .SH COPYRIGHT Copyright (C) 2001 Information\-technology Promotion Agency (IPA) .br Copyright (C) 2001\-2011 National Institute of Advanced Industrial Science and Technology (AIST) .br Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License .