xref: /titanic_52/usr/src/lib/iconv_modules/ko/common/johap_to_wansung.c (revision 91e1e26ac6a73ce959289cf7d3d96c4baedbe0b8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1994 by Sun Microsystems, Inc.
23  */
24 
25 
26 #include <errno.h>
27 #include "ktable.h"
28 #include "hangulcode.h"
29 
30 
31 /****  _ J O H A P _ T O _ W A N S U N G  ****/
32 
33 unsigned short _johap_to_wansung(unsigned short ci, unsigned short v,
34 					unsigned short cf)
35 {
36 	register unsigned short	i;
37 	unsigned short		code, mask, disp;
38 	long			cfbit;
39 
40 	if (ci <= 18 && v == CVC_FILL && cf == CVC_FILL)
41 		return(0xA4A0 + Y19_32[ci + 1]);
42 	else if (ci == CVC_FILL && v <= 20 && cf == CVC_FILL)
43 		return(0xA4BF + v);
44 	else if (ci != CVC_FILL && ci <= 18 && v != CVC_FILL && v <= 20)
45 	{
46 		 if (cf == CVC_FILL)
47 			cf = 1;
48 
49 		cfbit = cmp_bitmap[ci][v];
50 		for (disp = 0, i = 0; i < cf; i++)
51 		{
52 			if (cfbit & BIT_MASK)
53 				disp++;
54 			cfbit >>= 1;
55 		}
56 		if (!(cfbit & BIT_MASK))
57 			return(FAILED);
58 
59 		code = cmp_srchtbl[ci][v] + disp;
60 		mask = cmp_srchtbl[ci][v] & 0xFF;
61 
62 		return(code + (((short)(mask + disp) > 0xFE) ? SKIP : 0));
63 	}
64 
65 	return(FAILED);
66 }  /* end of unsigned short _johap_to_wansung(unsigned short, unsigned short,
67     *						unsigned short). */
68