udcInf.c 17.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
/*
Copyright 1996, 1998  The Open Group

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.

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
 * Copyright 1995 by FUJITSU LIMITED
 * This is source code modified by FUJITSU LIMITED under the Joint
 * Development Agreement for the CDE/Motif PST.
 *
 * Modifier: Takanori Tateno   FUJITSU LIMITED
 *
 */


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <locale.h>
#include <Xlib.h>
#include <Xlibint.h>
#include <Xlcint.h>
#include <XlcPubI.h>
#include <XlcGeneric.h>
#include <XomGeneric.h>

/*
   external symbols 
*/
extern FontData read_EncodingInfo();
extern int _xudc_get_codeset();

extern int _xudc_utyderror ;
extern int _xudc_utyerror ;

extern unsigned long _xudc_utyerrno ;

#define _XUDC_ERROR -1


/*
    UDC structure define
*/
typedef struct __XUDCGlyphRegion {
    unsigned long  start;
    unsigned long  end;
} _XUDCGlyphRegion ;

/*
 *  "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu.
 */
static unsigned char getbyte(code,i)
unsigned long code;
int	      i;
{
    unsigned long byteL;
    unsigned char byte;
    byteL = code  >> (8*(3-i));
    byte = (unsigned char)(0x000000ff & byteL);
    return(byte);
}
/*
    get codeset which described by charset_str and locale.
    for examples ...
    locale          :  ja_JP
    charset_str     :  JISX0208.1983-0
*/

_xudc_get_codeset(locale,charset_str,codeset,num_codeset)
char *locale;
char *charset_str;
int  **codeset;
int  *num_codeset;
{
    XLCdRec lcdrec;
    XLCd     lcd;
    XLCdPublicRec xlcdp;
    XPointer rdb;
    int num = 0,count,num_ret=0,i,*ret;
    char **value,buf[128],*ptr;


    _xudc_utyderror = 0;
    _xudc_utyerror = 0;

    if((locale == NULL) || (charset_str == NULL)){
        _xudc_utyerror = 5;
        _xudc_utyderror = 1;
	_xudc_utyerrno = 0x04 ;
        return(_XUDC_ERROR);
    }
    if(codeset == NULL){
        _xudc_utyerror = 5;
        _xudc_utyderror = 2;
	_xudc_utyerrno = 0x04 ;
        return(_XUDC_ERROR);
    }

    /*    create XLCd     */
    xlcdp.pub.siname = locale;
    lcdrec.core = (XLCdCore)&xlcdp;
    lcd = &lcdrec;
        /* create X RDB (X NLS DB) */
    rdb = _XlcCreateLocaleDataBase(lcd);
    if(rdb == NULL){
        _xudc_utyerror = 1;
	_xudc_utyerrno = 0x15 ;
        return(_XUDC_ERROR);
    }

    for(num=0;;num++){
        /* XLC_FONTSET */
        sprintf(buf, "fs%d.font.primary", num);
        _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
        if(count < 1){
            break ;
        }
        for(i=0;i<count;i++){
	    if (strlen(value[i]) >= sizeof(buf))
		continue;
            strcpy(buf,value[i]);
            ptr = (char *)strchr(buf,(int)':');
            *ptr = 0;
            if(!_XlcCompareISOLatin1(charset_str,buf)){
                num_ret += 1;
                if(num_ret == 1){
                    ret = (int *)Xmalloc(sizeof(int));
                } else {
		    int *prev_ret = ret;

		    ret = 
                        (int *)Xrealloc(ret,num_ret*sizeof(int)); 
		    if (ret == NULL){
			Xfree(prev_ret);
		    }
                }
                if(ret == NULL){
		    _xudc_utyerrno = 0x03 ;
                    return(_XUDC_ERROR);
                }
		ret[num_ret-1]=num;
                break ;
            }
        }
    }
    if(num_ret == 0){
        *num_codeset = 0;
        *codeset = NULL;
        return (0xff);
    }

    *num_codeset = num_ret;
    *codeset = ret;
    return 0;
}

static Bool gi_to_vgi(gi,vgi,scope)
unsigned long 	gi,*vgi;
FontScope	scope;
{
    if(scope->shift_direction == (unsigned long)'+'){
        gi  -= scope->shift;
    } else {
        gi  += scope->shift;
    }
    if(gi >= scope->start && gi <= scope->end){
	*vgi = gi;
        return(True);
    }
    return(False);
}

static void shift_area(udc,scope)
_XUDCGlyphRegion *udc;
FontScope scope;
{
    if(scope->shift_direction == (unsigned long)'+'){
        udc->start += scope->shift;
        udc->end   += scope->shift;
    } else {
        udc->start -= scope->shift;
        udc->end   -= scope->shift;
    }
}

/*
    get UDC area with glyph index.
    for examples ...
    locale          :  ja_JP
    charset_str     :  JISX0208.1983-0
*/
_XUDCGetUDCGIArea(locale,codeset,charset_str,gr,num_gr)
char *locale;
int codeset;
char *charset_str;
_XUDCGlyphRegion  **gr;
int  *num_gr;
{
    XLCdRec lcdrec;
    XLCd     lcd;
    XLCdPublicRec xlcdp;
    XPointer rdb;
    _XUDCGlyphRegion *udc;
    int num = 0,count,num_ret=0;
    int i,j,k;
    char **value,buf[128],ptr;
    FontData font_data;


    _xudc_utyderror = 0;
    _xudc_utyerror = 0;
    _xudc_utyerrno = 0x00 ;

    if((locale == NULL) || (charset_str == NULL)){
        _xudc_utyerror = 5;
        _xudc_utyderror = 1;
	_xudc_utyerrno = 0x04;
	_xudc_utyerrno |= (0x0b<<8) ;
        return(_XUDC_ERROR);
    }
    if(gr == NULL){
        _xudc_utyerror = 5;
        _xudc_utyderror = 1;
	_xudc_utyerrno = 0x04;
	_xudc_utyerrno |= (0x0b<<8) ;
        return(_XUDC_ERROR);
    }
    if(num_gr == NULL){
        _xudc_utyerror = 5;
        _xudc_utyderror = 2;
	_xudc_utyerrno = 0x04;
	_xudc_utyerrno |= (0x0b<<8) ;
        return(_XUDC_ERROR);
    }

        /* create XLCd */
    xlcdp.pub.siname = locale;
    lcdrec.core = (XLCdCore)&xlcdp;
    lcd = &lcdrec;
        /* create X RDB (X NLS DB) */
    rdb = _XlcCreateLocaleDataBase(lcd);
    if(rdb == NULL){
        _xudc_utyerror = 1;
	_xudc_utyerrno = 0x15 ;
	_xudc_utyerrno |= (0x0b<<8) ;
        return(_XUDC_ERROR);
    }
    udc = NULL;

        /* XLC_FONTSET */
        sprintf(buf, "fs%d.charset.udc_area", codeset-1);
        _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
        if(count > 0){
            udc = (_XUDCGlyphRegion *)Xmalloc(count * sizeof(_XUDCGlyphRegion));
            if(udc == NULL){
		_xudc_utyerrno = 0x03 ;
		_xudc_utyerrno |= (0x0b<<8) ;
		return(_XUDC_ERROR);
            }
            for(i=0;i<count;i++){
                sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end));
            }
        }

    *num_gr = count;

        sprintf(buf, "fs%d.font.primary", codeset-1);
        _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
        if(count > 0){
	    font_data = read_EncodingInfo(count,value);
            for(i=0;i<count;i++){
                if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
                    for(j=0;j<(*num_gr);j++){
                    	for(k=0;k<font_data[i].scopes_num;k++){
			    if(udc[j].start == font_data[i].scopes[k].start
                                  && font_data[i].scopes[k].shift){
                                shift_area(&udc[j],&(font_data[i].scopes[k]));
                            }
			}
		    }
		}
	    }
        }

    *gr = udc;
    return 0;
}

/* 
 *      Code convert wo tomonau UDC area no kakutoku
 *      GetUDCCPArea() / glyph_to_code()           
 *
 */

static int
_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,gi,vgi,charsetname,size)
XLCd 	lcd;
char 	*locale;
char 	*charset_str;
int 	codeset;
unsigned long 	gi;
unsigned long 	*vgi;
char    *charsetname;
int	size;
{
    _XUDCGlyphRegion *udc;
    int num = 0,count,num_ret=0;
    int i,j,k;
    char **value,buf[128],ptr;
    FontData font_data;


    sprintf(buf, "fs%d.charset.name", codeset-1);
    _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
    if(count > 0){
        strcpy(charsetname,value[0]);
    }
    if (count >= size)
	return False;
    sprintf(buf, "fs%d.font.primary", codeset-1);
    _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
    if(count > 0){
	font_data = read_EncodingInfo(count,value);
        for(i=0;i<count;i++){
            if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
                for(k=0;k<font_data[i].scopes_num;k++){
	            if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
			return(True);
                    }
	        }
	    }
        }
    }
/*
    free_fontdata(font_data);
*/
    *vgi = gi;
    return(True);
}

Bool non_standard(lcd,charset)
XLCd 	lcd;
XlcCharSet 	charset;
{
    char buf[256];
    int count,i;
    char **value;
    if(charset->ct_sequence == NULL){
            return(False);
    }
    for(i=0;;i++){
	sprintf(buf, "csd%d.charset_name", i);
	_XlcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count);
	if(count > 0){
	    if(!_XlcNCompareISOLatin1(value[0], 
			charset->name,strlen(value[0])) ){
		return(True);
	    }
	} else {
            return(False);
	}
    }
}

static Bool
make_none_standard(from,charset,src,size)
char *from;
XlcCharSet 	charset;
char *src;
int size;
{
    int name_len,seq_len,rest_len,i;
    name_len = 2 + strlen(charset->encoding_name) + 1;
    seq_len = strlen(charset->ct_sequence);
    rest_len = strlen(charset->encoding_name) + 1 + strlen(src);
    if (name_len + seq_len + strlen(src) >= size || rest_len >= 0x4000)
	return False;
    strcpy(from,charset->ct_sequence);
    from[seq_len]    = (rest_len >> 7) + 128;
    from[seq_len+1]  = (rest_len & 0x7f) + 128;
    strcpy(&from[seq_len + 2],charset->encoding_name);
    from[seq_len+name_len-1]  = 0x02;  /* STX */
    strcpy(&from[seq_len + name_len],src);
    return True;
}
int 
_xudc_glyph_to_code(locale,charset_str,codeset,glyph_index,codepoint)
char 	*locale;
char 	*charset_str;
int 	codeset;
unsigned long 	glyph_index;
unsigned long 	*codepoint;
{
    XLCd 	lcd;
    unsigned char *from; int	from_left;
    unsigned char *to  ; int 	to_left = 10;
    unsigned char *dst;
    unsigned char byte;
    unsigned long from32[25];
    unsigned long to32[25];
    int	     i,j;
    char charsetname[256],src[10];
    XlcConv 	conv;
    XlcCharSet 	charset;
    XPointer args[2];

    from = (unsigned char *)from32;
    to   = (unsigned char *)to32;
    dst  = (unsigned char *)to32;

    memset(dst,0,25);
	
    lcd = (XLCd)_XlcGenericLoader(locale);

    if (!_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,
	glyph_index,&glyph_index,charsetname,sizeof(charsetname)))
	return(_XUDC_ERROR);

    for(i=0,j=0;i<4;i++){
	byte = getbyte(glyph_index,i);
	if(byte){
	    src[j] = byte;
            j ++;
	}
    }
    src[j] = 0;


    /* get charset */
/*
    sprintf(tmp,"%s%s",charset_str,":GL");
    charset_name = strdup(tmp);
*/
    charset = _XlcGetCharSet(charsetname);
    if(charset == NULL){
	_xudc_utyerrno = 0x16 ;
	return(_XUDC_ERROR);
    }
    /* make ct */
    if( non_standard(lcd,charset)) {
        if (!make_none_standard(from,charset,src,sizeof(from32)))
	    return(_XUDC_ERROR);
    } else if(charset->ct_sequence){
	if (strlen(charset->ct_sequence) + strlen(src) >= sizeof(from32))
	    return(_XUDC_ERROR);
        sprintf((char *)from,"%s%s",charset->ct_sequence,src);
    } else {
        sprintf((char *)from,"%s\0",src);
    }
    /* compound text -> multi byte */
    conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
    from_left = strlen((char *)from);
    _XlcConvert(conv,(XPointer *)&from,&from_left,
                     (XPointer *)&to,  &to_left,args,0);
    _XlcCloseConverter(conv);
    _XlcDestroyLC(lcd);

    *codepoint = 0;
    for(i=0;dst[i];i++){
        *codepoint = ((*codepoint << 8) | dst[i]) ;
    }
    return(0);
}

typedef struct __XUDCCodeRegion {
	unsigned long start,end;
} _XUDCCodeRegion ;

int
_XUDCGetUDCCPArea(locale,codeset,charset_str,cr,num_cr)
char 		*locale;
int 		codeset;
char 		*charset_str;
_XUDCCodeRegion **cr;
int  *num_cr;
{
    int i,num_gr,ret;
    _XUDCGlyphRegion *gr;
    _XUDCCodeRegion  *crr;

    _xudc_utyerror  = 0;
    _xudc_utyderror = 0;

    if(cr == NULL){
        _xudc_utyerror  = 5;
        _xudc_utyderror = 1;
	_xudc_utyerrno = 0x04 ;
	_xudc_utyerrno |= (0x0a<<8) ;
        return(_XUDC_ERROR);
    }
    if(num_cr == NULL){
        _xudc_utyerror  = 5;
        _xudc_utyderror = 2;
	_xudc_utyerrno = 0x04 ;
	_xudc_utyerrno |= (0x0a<<8) ;
        return(_XUDC_ERROR);
    }

    ret = _XUDCGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr);
    if(ret == _XUDC_ERROR){
	_xudc_utyerrno &= 0xff ;
	_xudc_utyerrno |= (0x0a<<8) ;
	return(ret);
    }

    crr = (_XUDCCodeRegion *)Xmalloc(num_gr*sizeof(_XUDCCodeRegion));
    if(crr == NULL){
	Xfree(gr);
	_xudc_utyerrno = 0x03 ;
	_xudc_utyerrno |= (0x0a<<8) ;
	return(_XUDC_ERROR);
    }

    for(i=0;i<num_gr;i++){
	ret = _xudc_glyph_to_code(locale,charset_str,codeset,
		gr[i].start, &(crr[i].start));
	if(ret == _XUDC_ERROR){
	    _xudc_utyerrno |= (0x0a<<8) ;
	    Xfree(gr);
	    Xfree(crr);
	    return(ret);
	}
	ret = _xudc_glyph_to_code(locale,charset_str,codeset,
		gr[i].end, &(crr[i].end));
	if(ret == _XUDC_ERROR){
	    _xudc_utyerrno |= (0x0a<<8) ;
	    Xfree(gr);
	    Xfree(crr);
	    return(ret);
	}
    }
    Xfree(gr);
    *cr = crr;
    *num_cr = num_gr;
    return(0);
}

/*
 *    code_to_glyph()
 *    
 */
typedef struct __XUDCGIInf {
    char 		*charset_str;
    unsigned long 	glyph_index;
} _XUDCGIInf ;

/*
 *
 *
 */
static Bool vgi_to_gi(gi,vgi,scope)
unsigned long 	*gi,vgi;
FontScope	scope;
{
    if(vgi >= scope->start && vgi <= scope->end){
        if(scope->shift_direction == (unsigned long)'+'){
            *gi = vgi + scope->shift;
        } else {
            *gi = vgi - scope->shift;
        }
        return(True);
    }
    return(False);
}
/*
 *
 *
 */
static Bool  
_xudc_vgi_to_gi(lcd,locale,vglyph,glyph,charset,charsetname,size)
XLCd    lcd;
char    *locale;
unsigned long   vglyph;
unsigned long   *glyph;
XlcCharSet	charset;
char    *charsetname;
int	size;
{
    int num = 0,count,num_ret=0;
    int i,j,k;
    char **value,buf[128],ptr;
    FontData font_data;
    CodeSet cs;

    
    for(i=0;;i++){
        sprintf(buf, "fs%d.charset.name",i);
        _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
        if(count > 0){
            if(!_XlcNCompareISOLatin1(charset->name,value[0],
			strlen(charset->name))){
		break;
	    }
        } else {
	    _xudc_utyerrno = 0x17 ;
	    return(False);
	}
    }
/*
    sprintf(buf, "fs%d.charset.name", codeset-1);
    _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
    if(count > 0){
        strcpy(charsetname,value[0]);
    }
*/
    sprintf(buf, "fs%d.font.primary", i);
    _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
    if(count > 0){
	font_data = read_EncodingInfo(count,value);
        for(i=0;i<count;i++){
            for(k=0;k<font_data[i].scopes_num;k++){
	        if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
		    if (strlen(font_data[i].name) >= size)
			return(False);
		    strcpy(charsetname,font_data[i].name);
		    return(True);
                }
	    }
        }
    }
    *glyph = vglyph;
    return(True);
}
int
_xudc_code_to_glyph(locale,codepoint,gi,num_gi)
char 		*locale;
unsigned long 	codepoint;
_XUDCGIInf 	**gi;
int 		*num_gi;
{
    XLCd        lcd;
    unsigned char *from; int    from_left;
    unsigned char *to  ; int    to_left = 10;
    unsigned char *dst;
    unsigned char byte;
    unsigned int from32[25];
    unsigned int to32[25];
    int      i,j;
    char charsetname[256],src[10];
    XlcConv     conv;
    XlcCharSet  charset;
    XPointer args[2];
    unsigned long glyph,vglyph;

    from = (unsigned char *)from32;
    to   = (unsigned char *)to32;
    dst  = (unsigned char *)to32;
    memset(dst,0,25);

    lcd = (XLCd)_XlcGenericLoader(locale);

    for(i=0,j=0;i<4;i++){
	byte = getbyte(codepoint,i);
	if(byte){
	    src[j] = byte;
            j ++;
	}
    }
    src[j] = 0;
    sprintf((char *)from,"%s\0",src);
    /* multi byte -> vgi */
    conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
    from_left = strlen((char *)from);
    args[0] = (XPointer) &charset;
    _XlcConvert(conv,(XPointer *)&from,&from_left,
                     (XPointer *)&to,  &to_left,args,1);

    /* vgi -> gi */
    vglyph = 0;
    for(i=0;dst[i];i++){
        vglyph = ((vglyph << 8) | dst[i]) ;
    }
    if(_xudc_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname,
			sizeof(charsetname))==False){
        _XlcCloseConverter(conv);
	_XlcDestroyLC(lcd);
        *num_gi = 0;
	return(0);
    }

    _XlcCloseConverter(conv);
    _XlcDestroyLC(lcd);

    *gi = (_XUDCGIInf *)Xmalloc(sizeof(_XUDCGIInf));
    (*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
    strcpy((*gi)->charset_str,charsetname);
    (*gi)->glyph_index = glyph;
    if(*gi == NULL){
	_xudc_utyerrno = 0x03 ;
        return(_XUDC_ERROR);
    }
    *num_gi = 1;
    return(0);
}