]>
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 wchar_t toLower(wchar_t c
)
35 wchar_t toUpper(wchar_t c
)
40 wchar_t foldCase(wchar_t c
)
45 bool isPrintableChar(wchar_t c
)
50 bool isSpace(wchar_t c
)
55 bool isLetter(wchar_t c
)
60 bool isUpper(wchar_t c
)
65 bool isLower(wchar_t c
)
70 bool isDigit(wchar_t c
)
75 bool isPunct(wchar_t c
)
80 int toLower(wchar_t* result
, int resultLength
, const wchar_t* source
, int sourceLength
, bool* isError
)
82 const UChar
* sourceIterator
= source
;
83 const UChar
* sourceEnd
= source
+ sourceLength
;
84 UChar
* resultIterator
= result
;
85 UChar
* resultEnd
= result
+ resultLength
;
87 int remainingCharacters
= 0;
88 if (sourceLength
<= resultLength
)
89 while (sourceIterator
< sourceEnd
)
90 *resultIterator
++ = towlower(*sourceIterator
++);
92 while (resultIterator
< resultEnd
)
93 *resultIterator
++ = towlower(*sourceIterator
++);
95 if (sourceIterator
< sourceEnd
)
96 remainingCharacters
+= sourceEnd
- sourceIterator
;
97 *isError
= (remainingCharacters
!= 0);
98 if (resultIterator
< resultEnd
)
101 return (resultIterator
- result
) + remainingCharacters
;
104 int toUpper(wchar_t* result
, int resultLength
, const wchar_t* source
, int sourceLength
, bool* isError
)
106 const UChar
* sourceIterator
= source
;
107 const UChar
* sourceEnd
= source
+ sourceLength
;
108 UChar
* resultIterator
= result
;
109 UChar
* resultEnd
= result
+ resultLength
;
111 int remainingCharacters
= 0;
112 if (sourceLength
<= resultLength
)
113 while (sourceIterator
< sourceEnd
)
114 *resultIterator
++ = towupper(*sourceIterator
++);
116 while (resultIterator
< resultEnd
)
117 *resultIterator
++ = towupper(*sourceIterator
++);
119 if (sourceIterator
< sourceEnd
)
120 remainingCharacters
+= sourceEnd
- sourceIterator
;
121 *isError
= (remainingCharacters
!= 0);
122 if (resultIterator
< resultEnd
)
125 return (resultIterator
- result
) + remainingCharacters
;
128 int foldCase(wchar_t* result
, int resultLength
, const wchar_t* source
, int sourceLength
, bool* isError
)
131 if (resultLength
< sourceLength
) {
135 for (int i
= 0; i
< sourceLength
; ++i
)
136 result
[i
] = foldCase(source
[i
]);
140 wchar_t toTitleCase(wchar_t c
)
145 Direction
direction(UChar32 c
)
147 return static_cast<Direction
>(UnicodeCE::direction(c
));
150 CharCategory
category(unsigned int c
)
152 return static_cast<CharCategory
>(TO_MASK((__int8
) UnicodeCE::category(c
)));
155 DecompositionType
decompositionType(UChar32 c
)
157 return static_cast<DecompositionType
>(UnicodeCE::decompositionType(c
));
160 unsigned char combiningClass(UChar32 c
)
162 return UnicodeCE::combiningClass(c
);
165 wchar_t mirroredChar(UChar32 c
)
167 return UnicodeCE::mirroredChar(c
);
170 int digitValue(wchar_t c
)
172 return UnicodeCE::digitValue(c
);
175 } // namespace Unicode