1 /*
2 * MSVCRT string functions
3 *
4 * Copyright 1996,1998 Marcus Meissner
5 * Copyright 1996 Jukka Iivonen
6 * Copyright 1997,2000 Uwe Bonnes
7 * Copyright 2000 Jon Griffiths
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25 #include <precomp.h>
26 #include <mbstring.h>
27 #include <locale.h>
28
29 /*
30 * @implemented
31 */
_mbcjistojms(unsigned int c)32 unsigned int _mbcjistojms(unsigned int c)
33 {
34 /* Conversion takes place only when codepage is 932.
35 In all other cases, c is returned unchanged */
36 if(get_mbcinfo()->mbcodepage == 932)
37 {
38 if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
39 LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
40 {
41 if(HIBYTE(c) % 2)
42 c += 0x1f;
43 else
44 c += 0x7d;
45
46 if(LOBYTE(c) >= 0x7F)
47 c += 0x1;
48
49 c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
50
51 if(HIBYTE(c) > 0x9f)
52 c += 0x4000;
53 }
54 else
55 return 0; /* Codepage is 932, but c can't be converted */
56 }
57
58 return c;
59 }
60
61