blob: 21ce3c59fa69f04cbd0103f32c0674493bf7fdc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*
* Author: Jean-Marc Lienher ( http://oksid.ch )
* Copyright 2000-2010 by O'ksi'D.
*
* This library is free software. Distribution and use rights are outlined in
* the file "COPYING" which should have been included with this file. If this
* file is missing or damaged, see the license at:
*
* https://www.fltk.org/COPYING.php
*
* Please see the following page on how to report bugs and issues:
*
* https://www.fltk.org/bugs.php
*/
/*
* This file is required on all platforms for UTF-8 support
*/
#include "../utf8_internal.h"
#include <stdlib.h>
/* include UCS tables */
#include "headers/case.h"
int
XUtf8Tolower(int ucs) {
int ret;
if (ucs <= 0x02B6) {
if (ucs >= 0x0041) {
ret = ucs_table_0041[ucs - 0x0041];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x0556) {
if (ucs >= 0x0386) {
ret = ucs_table_0386[ucs - 0x0386];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x10C5) {
if (ucs >= 0x10A0) {
ret = ucs_table_10A0[ucs - 0x10A0];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x1FFC) {
if (ucs >= 0x1E00) {
ret = ucs_table_1E00[ucs - 0x1E00];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x2133) {
if (ucs >= 0x2102) {
ret = ucs_table_2102[ucs - 0x2102];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x24CF) {
if (ucs >= 0x24B6) {
ret = ucs_table_24B6[ucs - 0x24B6];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0x33CE) {
if (ucs >= 0x33CE) {
ret = ucs_table_33CE[ucs - 0x33CE];
if (ret > 0) return ret;
}
return ucs;
}
if (ucs <= 0xFF3A) {
if (ucs >= 0xFF21) {
ret = ucs_table_FF21[ucs - 0xFF21];
if (ret > 0) return ret;
}
return ucs;
}
return ucs;
}
int
XUtf8Toupper(int ucs) {
int i;
static unsigned short *table = NULL;
if (!table) {
table = (unsigned short*) malloc(sizeof(unsigned short) * 0x10000);
for (i = 0; i < 0x10000; i++) {
table[i] = (unsigned short) i;
}
for (i = 0; i < 0x10000; i++) {
int l;
l = XUtf8Tolower(i);
if (l != i) table[l] = (unsigned short) i;
}
}
if (ucs >= 0x10000 || ucs < 0) return ucs;
return table[ucs];
}
|