1/*	$OpenBSD: wctoint.h,v 1.2 2015/09/13 11:38:08 guenther Exp $	*/
2/* $NetBSD: __wctoint.h,v 1.1 2001/09/28 11:25:37 yamt Exp $ */
3
4/*-
5 * Copyright (c)2001 Citrus Project,
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 *	$Citrus: xpg4dl/FreeBSD/lib/libc/locale/__wctoint.h,v 1.1 2001/09/21 13:52:32 yamt Exp $
30 */
31
32
33inline static int
34wctoint(wchar_t wc)
35{
36	int n;
37
38	switch (wc) {
39	case L'0': n = 0; break;
40	case L'1': n = 1; break;
41	case L'2': n = 2; break;
42	case L'3': n = 3; break;
43	case L'4': n = 4; break;
44	case L'5': n = 5; break;
45	case L'6': n = 6; break;
46	case L'7': n = 7; break;
47	case L'8': n = 8; break;
48	case L'9': n = 9; break;
49	case L'A': case L'a': n = 10; break;
50	case L'B': case L'b': n = 11; break;
51	case L'C': case L'c': n = 12; break;
52	case L'D': case L'd': n = 13; break;
53	case L'E': case L'e': n = 14; break;
54	case L'F': case L'f': n = 15; break;
55	case L'G': case L'g': n = 16; break;
56	case L'H': case L'h': n = 17; break;
57	case L'I': case L'i': n = 18; break;
58	case L'J': case L'j': n = 19; break;
59	case L'K': case L'k': n = 20; break;
60	case L'L': case L'l': n = 21; break;
61	case L'M': case L'm': n = 22; break;
62	case L'N': case L'n': n = 23; break;
63	case L'O': case L'o': n = 24; break;
64	case L'P': case L'p': n = 25; break;
65	case L'Q': case L'q': n = 26; break;
66	case L'R': case L'r': n = 27; break;
67	case L'S': case L's': n = 28; break;
68	case L'T': case L't': n = 29; break;
69	case L'U': case L'u': n = 30; break;
70	case L'V': case L'v': n = 31; break;
71	case L'W': case L'w': n = 32; break;
72	case L'X': case L'x': n = 33; break;
73	case L'Y': case L'y': n = 34; break;
74	case L'Z': case L'z': n = 35; break;
75	default: n = -1; break; /* error */
76	}
77
78	return n;
79}
80