Mercurial > kinput2.yaz
comparison lib/Xsj3clib/code.c @ 0:92745d501b9a
initial import from kinput2-v3.1
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 08 Mar 2010 04:44:30 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92745d501b9a |
---|---|
1 #ifndef lint | |
2 static char *rcsid = "$Id: code.c,v 2.1 1993/09/21 09:43:46 nao Exp $"; | |
3 #endif | |
4 /* | |
5 * Copyright 1991 Sony Corporation | |
6 * | |
7 * Permission to use, copy, modify, distribute, and sell this software and its | |
8 * documentation for any purpose is hereby granted without fee, provided that | |
9 * the above copyright notice appear in all copies and that both that | |
10 * copyright notice and this permission notice appear in supporting | |
11 * documentation, and that the name of Sony not be used in advertising or | |
12 * publicity pertaining to distribution of the software without specific, | |
13 * written prior permission. Sony makes no representations about the | |
14 * suitability of this software for any purpose. It is provided "as is" | |
15 * without express or implied warranty. | |
16 * | |
17 * SONY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL | |
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SONY | |
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 */ | |
24 /* | |
25 * Author: Naoshi Suzuki, SONY Corporation. (nao@sm.sony.co.jp) | |
26 */ | |
27 | |
28 #include "common.h" | |
29 | |
30 #define WMASK 0x7f7f | |
31 #define WMSB 0x8080 | |
32 | |
33 wchar _Xsj3csjis2euc(); | |
34 wchar _Xsj3ceuc2sjis(); | |
35 wchar _Xsj3csjis2jis(); | |
36 wchar _Xsj3cjis2sjis(); | |
37 wchar _Xsj3cjis2euc(); | |
38 wchar _Xsj3ceuc2jis(); | |
39 | |
40 wchar | |
41 _Xsj3csjis2euc (c) | |
42 register wchar c; | |
43 { | |
44 register int high, low; | |
45 | |
46 if (c >= 0xf040) | |
47 return 0; | |
48 high = (c >> 8) & 0xff; | |
49 low = c & 0xff; | |
50 if (high > 0x9f) | |
51 high -= 0x40; | |
52 if (low > 0x9e) | |
53 return (((high << 9) | low) - 0x5ffe); | |
54 if (low > 0x7f) | |
55 low--; | |
56 return (((high << 9) | low) - 0x609f); | |
57 } | |
58 | |
59 wchar | |
60 _Xsj3ceuc2sjis (c) | |
61 register wchar c; | |
62 { | |
63 register int high, low; | |
64 | |
65 high = (c >> 8) & 0xff; | |
66 low = c & 0xff; | |
67 if (!(high & 1)) | |
68 low -= 0x02; | |
69 else if (low < 0xe0) | |
70 low -= 0x61; | |
71 else | |
72 low -= 0x60; | |
73 high = ((high - 0xa1) >> 1) + (high < 0xdf ? 0x81 : 0xc1); | |
74 return ((high << 8) | low); | |
75 } | |
76 | |
77 wchar | |
78 _Xsj3csjis2jis (c) | |
79 register wchar c; | |
80 { | |
81 register int high, low; | |
82 | |
83 if (c >= 0xf040) | |
84 return 0; | |
85 high = (c >> 8) & 0xff; | |
86 low = c & 0xff; | |
87 if (high > 0x9f) | |
88 high -= 0x40; | |
89 if (low > 0x9e) | |
90 return (((high << 9) | low) - 0xe07e); | |
91 if (low > 0x7f) | |
92 low--; | |
93 return (((high << 9) | low) - 0xe11f); | |
94 } | |
95 | |
96 wchar | |
97 _Xsj3cjis2sjis (c) | |
98 register wchar c; | |
99 { | |
100 register int high, low; | |
101 | |
102 high = (c >> 8) & 0xff; | |
103 low = c & 0xff; | |
104 if (!(high & 1)) | |
105 low += 0x7e; | |
106 else if (low < 0x60) | |
107 low += 0x1f; | |
108 else | |
109 low += 0x20; | |
110 high = ((high - 0x21) >> 1) + (high < 0x5f ? 0x81 : 0xc1); | |
111 return ((high << 8) | low); | |
112 } | |
113 | |
114 wchar | |
115 _Xsj3cjis2euc (c) | |
116 register wchar c; | |
117 { | |
118 return (c | WMSB); | |
119 } | |
120 | |
121 wchar | |
122 _Xsj3ceuc2jis (c) | |
123 register wchar c; | |
124 { | |
125 return (c & WMASK); | |
126 } |