/* $XConsortium: XmbTextPrp.c,v 1.6 91/11/17 15:31:30 rws Exp $ */
* Copyright 1991 by OMRON Corporation
* Copyright 1991 by the Massachusetts Institute of Technology
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of OMRON and MIT not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OMRON and MIT make no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
* OMRON AND MIT DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OMRON OR MIT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
* Author: Hiroshi Kuribayashi OMRON Corporation
#define XA_COMPOUND_TEXT(d) XInternAtom(d, "COMPOUND_TEXT", False)
#if NeedFunctionPrototypes
XmbTextListToTextProperty(
XmbTextListToTextProperty(dpy
, list
, count
, style
, text_prop
)
XTextProperty
*text_prop
;
unsigned char *buf
, *buf_sv
;
register unsigned int nbytes
;
for (i
= 0, nbytes
= 0; i
< count
; i
++) {
nbytes
+= (unsigned) ((list
[i
] ? strlen (list
[i
]) : 0) + 1);
datalen
= len
= nbytes
* 6 + 6; /* Is it correct/enough ? */
buf_sv
= buf
= (unsigned char *)Xmalloc((unsigned)len
);
if (!buf
) return (XNoMemory
);
proto
.value
= (unsigned char *) buf
;
if (style
== XStringStyle
) {
proto
.encoding
= XA_STRING
;
for (i
= 0; i
< count
; i
++, list
++) {
if ((ret
= _XConvertMBToString((unsigned char *)(*list
),
return (XConverterNotFound
);
} else if (style
== XCompoundTextStyle
) {
proto
.encoding
= XA_COMPOUND_TEXT(dpy
);
for (i
= 0; i
< count
; i
++, list
++) {
if ((ret
= _XConvertMBToCT(0, (unsigned char *)(*list
),
return (XConverterNotFound
);
} else if (style
== XTextStyle
) { /* MB: need not to convert */
XsiLCd lcd
= (XsiLCd
)_XlcCurrentLC();
proto
.nitems
= nbytes
- 1;
proto
.encoding
= XInternAtom(dpy
,
lcd
->xlc
->xlc_db
->lc_encoding
,
proto
.encoding
= XA_STRING
;
for (i
= 0; i
< count
; i
++, list
++) {
(void) strcpy((char *)buf
, *list
);
buf
+= (strlen(*list
) + 1);
} else if (style
== XStdICCTextStyle
) {
int is_xstring
= 1; /* Yes */
for (i
= 0; i
< count
; i
++, list
++) {
if ((ret
= _XConvertMBToCT(0, (unsigned char *)*list
,
buf
, &len
, &scand
, 0)) < 0) {
return (XConverterNotFound
);
for (i
= 0; *(buf
+i
); i
++) {
if (!_isXString(*(buf
+i
))) {
is_xstring
= 0; /* Not XString */
proto
.encoding
= XA_STRING
;
proto
.encoding
= XA_COMPOUND_TEXT(dpy
);
/* I don't know such a encoding */
return (XConverterNotFound
);