blob: 6e9ac67c32557b04db8b0376c34830c72d7c7b2d [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001/*
2 * "$Id: $"
3 *
4 * Author: Jean-Marc Lienher ( http://oksid.ch )
5 * Copyright 2000-2010 by O'ksi'D.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA.
21 *
22 * Please report all bugs and problems on the following page:
23 *
24 * http://www.fltk.org/str.php
25 */
26
27/*
28 * This file is required on all platforms for utf8 support
29 */
30
31#include "headers/case.h"
32#include <stdlib.h>
33
34int
35XUtf8Tolower(int ucs) {
36 int ret;
37 if (ucs <= 0x02B6) {
38 if (ucs >= 0x0041) {
39 ret = ucs_table_0041[ucs - 0x0041];
40 if (ret > 0) return ret;
41 }
42 return ucs;
43 }
44
45 if (ucs <= 0x0556) {
46 if (ucs >= 0x0386) {
47 ret = ucs_table_0386[ucs - 0x0386];
48 if (ret > 0) return ret;
49 }
50 return ucs;
51 }
52
53 if (ucs <= 0x10C5) {
54 if (ucs >= 0x10A0) {
55 ret = ucs_table_10A0[ucs - 0x10A0];
56 if (ret > 0) return ret;
57 }
58 return ucs;
59 }
60
61 if (ucs <= 0x1FFC) {
62 if (ucs >= 0x1E00) {
63 ret = ucs_table_1E00[ucs - 0x1E00];
64 if (ret > 0) return ret;
65 }
66 return ucs;
67 }
68
69 if (ucs <= 0x2133) {
70 if (ucs >= 0x2102) {
71 ret = ucs_table_2102[ucs - 0x2102];
72 if (ret > 0) return ret;
73 }
74 return ucs;
75 }
76
77 if (ucs <= 0x24CF) {
78 if (ucs >= 0x24B6) {
79 ret = ucs_table_24B6[ucs - 0x24B6];
80 if (ret > 0) return ret;
81 }
82 return ucs;
83 }
84
85 if (ucs <= 0x33CE) {
86 if (ucs >= 0x33CE) {
87 ret = ucs_table_33CE[ucs - 0x33CE];
88 if (ret > 0) return ret;
89 }
90 return ucs;
91 }
92
93 if (ucs <= 0xFF3A) {
94 if (ucs >= 0xFF21) {
95 ret = ucs_table_FF21[ucs - 0xFF21];
96 if (ret > 0) return ret;
97 }
98 return ucs;
99 }
100
101 return ucs;
102}
103
104int
105XUtf8Toupper(int ucs) {
106 int i;
107 static unsigned short *table = NULL;
108
109 if (!table) {
110 table = (unsigned short*) malloc(sizeof(unsigned short) * 0x10000);
111 for (i = 0; i < 0x10000; i++) {
112 table[i] = (unsigned short) i;
113 }
114 for (i = 0; i < 0x10000; i++) {
115 int l;
116 l = XUtf8Tolower(i);
117 if (l != i) table[l] = (unsigned short) i;
118 }
119 }
120 if (ucs >= 0x10000 || ucs < 0) return ucs;
121 return table[ucs];
122}
123
124/*
125* End of "$Id$".
126*/