Changeset 18712 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Jan 9, 2007, 6:54:26 AM (18 years ago)
- Location:
- trunk/JavaScriptCore/wtf/unicode
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h
r18247 r18712 4 4 * Copyright (C) 2006 George Staikos <[email protected]> 5 5 * Copyright (C) 2006 Alexey Proskuryakov <[email protected]> 6 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. 6 7 * 7 8 * This library is free software; you can redistribute it and/or … … 118 119 }; 119 120 120 inline uint32_t foldCase(uint32_tc)121 inline UChar32 foldCase(UChar32 c) 121 122 { 122 123 return u_foldCase(c, U_FOLD_CASE_DEFAULT); 123 124 } 124 125 125 inline int foldCase(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)126 inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 126 127 { 127 128 UErrorCode status = U_ZERO_ERROR; 128 int 32_trealLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status);129 int realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_CASE_DEFAULT, &status); 129 130 *error = !U_SUCCESS(status); 130 131 return realLength; 131 132 } 132 133 133 inline int toLower( uint16_t* str, int strLength, uint16_t*& destIfNeeded)134 inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded) 134 135 { 135 136 UErrorCode err = U_ZERO_ERROR; … … 137 138 destIfNeeded = 0; 138 139 139 resultLength = u_strToLower(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);140 resultLength = u_strToLower(0, 0, str, strLength, "", &err); 140 141 141 142 if (resultLength <= strLength) { 142 143 err = U_ZERO_ERROR; 143 u_strToLower( reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);144 u_strToLower(str, resultLength, str, strLength, "", &err); 144 145 } else { 145 146 err = U_ZERO_ERROR; 146 destIfNeeded = (uint16_t*)malloc(resultLength * sizeof(uint16_t));147 u_strToLower( reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);147 destIfNeeded = static_cast<UChar*>(malloc(resultLength * sizeof(UChar))); 148 u_strToLower(destIfNeeded, resultLength, str, strLength, "", &err); 148 149 } 149 150 … … 151 152 } 152 153 153 inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)154 inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 154 155 { 155 156 UErrorCode status = U_ZERO_ERROR; 156 int 32_trealLength = u_strToLower(result, resultLength, src, srcLength, "", &status);157 int realLength = u_strToLower(result, resultLength, src, srcLength, "", &status); 157 158 *error = !!U_FAILURE(status); 158 159 return realLength; 159 160 } 160 161 161 inline int32_t toLower(int32_tc)162 inline UChar32 toLower(UChar32 c) 162 163 { 163 164 return u_tolower(c); 164 165 } 165 166 166 inline int32_t toUpper(int32_tc)167 inline UChar32 toUpper(UChar32 c) 167 168 { 168 169 return u_toupper(c); 169 170 } 170 171 171 inline int toUpper( uint16_t* str, int strLength, uint16_t*& destIfNeeded)172 inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded) 172 173 { 173 174 UErrorCode err = U_ZERO_ERROR; … … 175 176 destIfNeeded = 0; 176 177 177 resultLength = u_strToUpper(0, 0, reinterpret_cast< ::UChar*>(str), strLength, "", &err);178 resultLength = u_strToUpper(0, 0, str, strLength, "", &err); 178 179 179 180 if (resultLength <= strLength) { 180 181 err = U_ZERO_ERROR; 181 u_strToUpper( reinterpret_cast< ::UChar*>(str), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);182 u_strToUpper(str, resultLength, str, strLength, "", &err); 182 183 } else { 183 184 err = U_ZERO_ERROR; 184 destIfNeeded = ( uint16_t*)malloc(resultLength * sizeof(uint16_t));185 u_strToUpper( reinterpret_cast< ::UChar*>(destIfNeeded), resultLength, reinterpret_cast< ::UChar*>(str), strLength, "", &err);185 destIfNeeded = (UChar*)malloc(resultLength * sizeof(UChar)); 186 u_strToUpper(destIfNeeded, resultLength, str, strLength, "", &err); 186 187 } 187 188 … … 189 190 } 190 191 191 inline int toUpper(UChar* result, int resultLength, UChar* src, int srcLength,bool* error)192 inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 192 193 { 193 194 UErrorCode status = U_ZERO_ERROR; 194 int 32_trealLength = u_strToUpper(result, resultLength, src, srcLength, "", &status);195 int realLength = u_strToUpper(result, resultLength, src, srcLength, "", &status); 195 196 *error = !!U_FAILURE(status); 196 197 return realLength; 197 198 } 198 199 199 inline int toTitleCase (uint32_tc)200 inline UChar32 toTitleCase(UChar32 c) 200 201 { 201 202 return u_totitle(c); 202 203 } 203 204 204 inline bool isFormatChar( int32_tc)205 inline bool isFormatChar(UChar32 c) 205 206 { 206 207 return u_charType(c) == U_FORMAT_CHAR; 207 208 } 208 209 209 inline bool isSeparatorSpace( int32_tc)210 inline bool isSeparatorSpace(UChar32 c) 210 211 { 211 212 return u_charType(c) == U_SPACE_SEPARATOR; 212 213 } 213 214 214 inline bool isPrintableChar( int32_tc)215 inline bool isPrintableChar(UChar32 c) 215 216 { 216 217 return !!u_isprint(c); 217 218 } 218 219 219 inline bool isDigit( int32_tc)220 inline bool isDigit(UChar32 c) 220 221 { 221 222 return !!u_isdigit(c); 222 223 } 223 224 224 inline bool isPunct( int32_tc)225 inline bool isPunct(UChar32 c) 225 226 { 226 227 return !!u_ispunct(c); 227 228 } 228 229 229 inline int32_t mirroredChar(int32_tc)230 inline UChar32 mirroredChar(UChar32 c) 230 231 { 231 232 return u_charMirror(c); 232 233 } 233 234 234 inline CharCategory category( int32_tc)235 inline CharCategory category(UChar32 c) 235 236 { 236 237 return static_cast<CharCategory>(U_GET_GC_MASK(c)); 237 238 } 238 239 239 inline Direction direction(int c) { 240 return (Direction)u_charDirection(c); 241 } 242 243 inline bool isLower(int32_t c) 240 inline Direction direction(UChar32 c) 241 { 242 return static_cast<Direction>(u_charDirection(c)); 243 } 244 245 inline bool isLower(UChar32 c) 244 246 { 245 247 return !!u_islower(c); 246 248 } 247 249 248 inline bool isUpper( int32_tc)250 inline bool isUpper(UChar32 c) 249 251 { 250 252 return !!u_isUUppercase(c); 251 253 } 252 254 253 inline int digitValue( int32_tc)255 inline int digitValue(UChar32 c) 254 256 { 255 257 return u_charDigitValue(c); … … 266 268 } 267 269 268 inline int strcasecmp(const UChar *a, const UChar *b, int len)270 inline int umemcasecmp(const UChar* a, const UChar* b, int len) 269 271 { 270 272 return u_memcasecmp(a, b, len, U_FOLD_CASE_DEFAULT); 271 273 } 272 274 273 inline void memset(UChar* dest, UChar ch, int32_t count)274 {275 u_memset(dest, ch, count);276 }277 275 } 278 276 } -
trunk/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h
r18161 r18712 143 143 }; 144 144 145 inline int toLower( uint16_t* str, int strLength, uint16_t*& destIfNeeded)145 inline int toLower(UChar* str, int strLength, UChar*& destIfNeeded) 146 146 { 147 147 destIfNeeded = 0; … … 153 153 } 154 154 155 inline uint16_t toLower(uint16_t ch) 156 { 157 return QChar(ch).toLower().unicode(); 158 } 159 160 inline int toLower(UChar* result, int resultLength, UChar* src, int srcLength, bool* error) 155 inline UChar32 toLower(UChar32 ch) 156 { 157 if (ch > 0xffff) 158 return ch; 159 return QChar((unsigned short)ch).toLower().unicode(); 160 } 161 162 inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error) 161 163 { 162 164 *error = false; … … 169 171 } 170 172 171 inline int toUpper( uint16_t* str, int strLength, uint16_t*& destIfNeeded)173 inline int toUpper(UChar* str, int strLength, UChar*& destIfNeeded) 172 174 { 173 175 destIfNeeded = 0; … … 179 181 } 180 182 181 inline uint16_t toUpper(uint16_t ch) 182 { 183 return QChar(ch).toUpper().unicode(); 183 inline UChar32 toUpper(UChar32 ch) 184 { 185 if (ch > 0xffff) 186 return ch; 187 return QChar((unsigned short)ch).toUpper().unicode(); 184 188 } 185 189 … … 195 199 } 196 200 197 inline int toTitleCase (uint32_tc)201 inline int toTitleCase(UChar32 c) 198 202 { 199 203 if (c > 0xffff) 200 204 return c; 201 return QChar( c).toUpper().unicode();202 } 203 204 inline uint32_t foldCase(uint32_tc)205 return QChar((unsigned short)c).toUpper().unicode(); 206 } 207 208 inline UChar32 foldCase(UChar32 c) 205 209 { 206 210 if (c > 0xffff) 207 211 return c; 208 return QChar( c).toLower().unicode();212 return QChar((unsigned short)c).toLower().unicode(); 209 213 } 210 214 … … 214 218 } 215 219 216 inline bool isFormatChar( int32_tc)220 inline bool isFormatChar(UChar32 c) 217 221 { 218 222 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format; 219 223 } 220 224 221 inline bool isPrintableChar( int32_tc)225 inline bool isPrintableChar(UChar32 c) 222 226 { 223 227 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPrint(); 224 228 } 225 229 226 inline bool isSeparatorSpace( int32_tc)230 inline bool isSeparatorSpace(UChar32 c) 227 231 { 228 232 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space; 229 233 } 230 234 231 inline bool isPunct( int32_tc)235 inline bool isPunct(UChar32 c) 232 236 { 233 237 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isPunct(); 234 238 } 235 239 236 inline bool isDigit( int32_tc)240 inline bool isDigit(UChar32 c) 237 241 { 238 242 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).isDigit(); 239 243 } 240 244 241 inline bool isLower( int32_tc)245 inline bool isLower(UChar32 c) 242 246 { 243 247 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Lowercase; 244 248 } 245 249 246 inline bool isUpper( int32_tc)250 inline bool isUpper(UChar32 c) 247 251 { 248 252 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Letter_Uppercase; 249 253 } 250 254 251 inline int digitValue( int32_tc)255 inline int digitValue(UChar32 c) 252 256 { 253 257 if (c > 0xffff) … … 256 260 } 257 261 258 inline uint16_t mirroredChar(uint16_t c) 259 { 262 inline UChar32 mirroredChar(UChar32 c) 263 { 264 if (c > 0xffff) 265 return c; 260 266 return QChar(c).mirroredChar().unicode(); 261 267 } … … 275 281 } 276 282 277 278 inline int strcasecmp(const UChar *a, const UChar *b, int len) 283 inline int umemcasecmp(const UChar* a, const UChar* b, int len) 279 284 { 280 285 for (int i = 0; i < len; ++i) { … … 287 292 } 288 293 289 inline void memset(UChar* dest, UChar ch, int32_t count) 290 { 291 UChar *end = dest + count; 292 while (dest < end) 293 *dest++ = ch; 294 } 295 296 inline Direction direction(int c) { 294 inline Direction direction(UChar32 c) { 297 295 if (c > 0xffff) 298 296 return LeftToRight; … … 300 298 } 301 299 302 inline CharCategory category( intc) {300 inline CharCategory category(UChar32 c) { 303 301 if (c > 0xffff) 304 302 return (CharCategory) U_MASK(QChar::Letter_Other); 305 303 return (CharCategory) U_MASK(QChar(c).category()); 306 304 } 305 307 306 } 308 307 }
Note:
See TracChangeset
for help on using the changeset viewer.