2
* Copyright (c) International Business Machines Corp., 2000
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12
* the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
* These APIs are based on the C library functions. The semantics
21
* should match the C functions but with expanded size operands.
23
* The upper/lower functions are based on a table created by mkupr.
24
* This is a compressed table of upper and lower case conversion.
35
extern signed char UniUpperTable[512];
36
extern UNICASERANGE UniUpperRange[];
39
* UniStrcpy: Copy a string
41
static inline UniChar *UniStrcpy(UniChar * ucs1, const UniChar * ucs2)
43
UniChar *anchor = ucs1; /* save the start of result string */
45
while ((*ucs1++ = *ucs2++));
51
* UniStrlen: Return the length of a string
53
static inline size_t UniStrlen(const UniChar * ucs1)
64
* UniStrncmp: Compare length limited string
66
static inline int UniStrncmp(const UniChar * ucs1, const UniChar * ucs2,
70
return 0; /* Null strings are equal */
71
while ((*ucs1 == *ucs2) && *ucs1 && --n) {
75
return (int) *ucs1 - (int) *ucs2;
80
* UniStrncpy: Copy length limited string with pad
82
static inline UniChar *UniStrncpy(UniChar * ucs1, const UniChar * ucs2,
85
UniChar *anchor = ucs1;
87
while (n-- && *ucs2) /* Copy the strings */
91
while (n--) /* Pad with nulls */
98
* UniToupper: Convert a unicode character to upper case
100
static inline UniChar UniToupper(register UniChar uc)
102
register UNICASERANGE *rp;
104
if (uc < sizeof(UniUpperTable)) { /* Latin characters */
105
return uc + UniUpperTable[uc]; /* Use base tables */
107
rp = UniUpperRange; /* Use range tables */
109
if (uc < rp->start) /* Before start of range */
110
return uc; /* Uppercase = input */
111
if (uc <= rp->end) /* In range */
112
return uc + rp->table[uc - rp->start];
113
rp++; /* Try next range */
116
return uc; /* Past last range */
121
* UniStrupr: Upper case a unicode string
123
static inline UniChar *UniStrupr(register UniChar * upin)
125
register UniChar *up;
128
while (*up) { /* For all characters */
129
*up = UniToupper(*up);
132
return upin; /* Return input pointer */