]>
git.saurik.com Git - apple/javascriptcore.git/blob - wtf/unicode/wince/UnicodeWinCE.cpp
2 * Copyright (C) 2006 George Staikos <staikos@kde.org>
3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
4 * Copyright (C) 2007-2009 Torch Mobile, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #include "UnicodeWinCE.h"
30 UChar
toLower(UChar c
)
35 UChar
toUpper(UChar c
)
40 UChar
foldCase(UChar c
)
45 bool isPrintableChar(UChar c
)
55 bool isLetter(UChar c
)
80 bool isAlphanumeric(UChar c
)
85 int toLower(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
)
87 const UChar
* sourceIterator
= source
;
88 const UChar
* sourceEnd
= source
+ sourceLength
;
89 UChar
* resultIterator
= result
;
90 UChar
* resultEnd
= result
+ resultLength
;
92 int remainingCharacters
= 0;
93 if (sourceLength
<= resultLength
)
94 while (sourceIterator
< sourceEnd
)
95 *resultIterator
++ = towlower(*sourceIterator
++);
97 while (resultIterator
< resultEnd
)
98 *resultIterator
++ = towlower(*sourceIterator
++);
100 if (sourceIterator
< sourceEnd
)
101 remainingCharacters
+= sourceEnd
- sourceIterator
;
102 *isError
= !!remainingCharacters
;
103 if (resultIterator
< resultEnd
)
106 return (resultIterator
- result
) + remainingCharacters
;
109 int toUpper(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
)
111 const UChar
* sourceIterator
= source
;
112 const UChar
* sourceEnd
= source
+ sourceLength
;
113 UChar
* resultIterator
= result
;
114 UChar
* resultEnd
= result
+ resultLength
;
116 int remainingCharacters
= 0;
117 if (sourceLength
<= resultLength
)
118 while (sourceIterator
< sourceEnd
)
119 *resultIterator
++ = towupper(*sourceIterator
++);
121 while (resultIterator
< resultEnd
)
122 *resultIterator
++ = towupper(*sourceIterator
++);
124 if (sourceIterator
< sourceEnd
)
125 remainingCharacters
+= sourceEnd
- sourceIterator
;
126 *isError
= !!remainingCharacters
;
127 if (resultIterator
< resultEnd
)
130 return (resultIterator
- result
) + remainingCharacters
;
133 int foldCase(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
)
136 if (resultLength
< sourceLength
) {
140 for (int i
= 0; i
< sourceLength
; ++i
)
141 result
[i
] = foldCase(source
[i
]);
145 UChar
toTitleCase(UChar c
)
150 Direction
direction(UChar32 c
)
152 return static_cast<Direction
>(UnicodeCE::direction(c
));
155 CharCategory
category(unsigned int c
)
157 return static_cast<CharCategory
>(TO_MASK((__int8
) UnicodeCE::category(c
)));
160 DecompositionType
decompositionType(UChar32 c
)
162 return static_cast<DecompositionType
>(UnicodeCE::decompositionType(c
));
165 unsigned char combiningClass(UChar32 c
)
167 return UnicodeCE::combiningClass(c
);
170 UChar
mirroredChar(UChar32 c
)
172 return UnicodeCE::mirroredChar(c
);
175 int digitValue(UChar c
)
177 return UnicodeCE::digitValue(c
);
180 } // namespace Unicode