webengine/osswebengine/WebCore/platform/symbian/ICUSymbian.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include <config.h>
       
    19 #include <e32base.h>
       
    20 #include <unicode/uchar.h>
       
    21 
       
    22 U_STABLE UChar32 U_EXPORT2
       
    23 u_tolower(UChar32 c) {
       
    24     return User::LowerCase(c);
       
    25 }
       
    26 
       
    27 U_STABLE UChar32 U_EXPORT2
       
    28 u_toupper(UChar32 c) {
       
    29     return User::UpperCase(c);
       
    30 }
       
    31 
       
    32 U_STABLE UCharDirection U_EXPORT2
       
    33 u_charDirection(UChar32 c) {
       
    34     switch (TChar(c).GetBdCategory()) {
       
    35         default:
       
    36         case TChar::ELeftToRight:
       
    37             return U_LEFT_TO_RIGHT;
       
    38         case TChar::ELeftToRightEmbedding:
       
    39             return U_LEFT_TO_RIGHT_EMBEDDING;
       
    40         case TChar::ELeftToRightOverride:
       
    41             return U_LEFT_TO_RIGHT_OVERRIDE;
       
    42         case TChar::ERightToLeft:
       
    43             return U_RIGHT_TO_LEFT;
       
    44         case TChar::ERightToLeftArabic:
       
    45             return U_RIGHT_TO_LEFT_ARABIC;
       
    46         case TChar::ERightToLeftEmbedding:
       
    47             return U_RIGHT_TO_LEFT_EMBEDDING;
       
    48         case TChar::ERightToLeftOverride:
       
    49             return U_RIGHT_TO_LEFT_OVERRIDE;
       
    50         case TChar::EPopDirectionalFormat:
       
    51             return U_POP_DIRECTIONAL_FORMAT;
       
    52         case TChar::EEuropeanNumber:
       
    53             return U_EUROPEAN_NUMBER;
       
    54         case TChar::EEuropeanNumberSeparator:
       
    55             return U_EUROPEAN_NUMBER_SEPARATOR;
       
    56         case TChar::EEuropeanNumberTerminator:
       
    57             return U_EUROPEAN_NUMBER_TERMINATOR;
       
    58         case TChar::EArabicNumber:
       
    59             return U_ARABIC_NUMBER;
       
    60         case TChar::ECommonNumberSeparator:
       
    61             return U_COMMON_NUMBER_SEPARATOR;
       
    62         case TChar::ENonSpacingMark:
       
    63             return U_DIR_NON_SPACING_MARK;
       
    64         case TChar::EBoundaryNeutral:
       
    65             return U_BOUNDARY_NEUTRAL;
       
    66         case TChar::EParagraphSeparator:
       
    67             return U_BLOCK_SEPARATOR;
       
    68         case TChar::ESegmentSeparator:
       
    69             return U_SEGMENT_SEPARATOR;
       
    70         case TChar::EWhitespace:
       
    71             return U_WHITE_SPACE_NEUTRAL;
       
    72         case TChar::EOtherNeutral:
       
    73             return U_OTHER_NEUTRAL;
       
    74     }
       
    75 }
       
    76 
       
    77 U_STABLE UBool U_EXPORT2
       
    78 u_ispunct(UChar32 c) {
       
    79     return TChar(c).IsPunctuation();
       
    80 }
       
    81 
       
    82 U_STABLE UChar32 U_EXPORT2
       
    83 u_foldCase(UChar32 c, uint32_t options) {
       
    84     TChar t(c);
       
    85     t.Fold();
       
    86     return t;
       
    87 }
       
    88 
       
    89 U_STABLE UBool U_EXPORT2
       
    90 u_islower(UChar32 c) {
       
    91     return TChar(c).IsLower();
       
    92 }
       
    93 
       
    94 U_STABLE int32_t U_EXPORT2
       
    95 u_charDigitValue(UChar32 c) {
       
    96     return TChar(c).GetNumericValue();
       
    97 }
       
    98 
       
    99 U_STABLE int8_t U_EXPORT2
       
   100 u_charType(UChar32 c) {
       
   101     switch (TChar(c).GetCategory()) {
       
   102         default:
       
   103         case TChar::ELlCategory:
       
   104             return U_LOWERCASE_LETTER; //Ll
       
   105         case TChar::ELuCategory:
       
   106             return U_UPPERCASE_LETTER; //Lu
       
   107         case TChar::ELoCategory:
       
   108             return U_OTHER_LETTER;     //Lo
       
   109         case TChar::ELtCategory:
       
   110             return U_TITLECASE_LETTER; //Lt
       
   111         case TChar::ENlCategory:
       
   112             return U_LETTER_NUMBER; //Nl
       
   113         case TChar::EMcCategory:
       
   114             return U_COMBINING_SPACING_MARK; //Mc
       
   115         case TChar::EMeCategory:
       
   116             return U_ENCLOSING_MARK;         //Me
       
   117         case TChar::EMnCategory:
       
   118             return U_NON_SPACING_MARK;       //Mn
       
   119         case TChar::ELmCategory:
       
   120             return U_MODIFIER_LETTER;       //Lm
       
   121         case TChar::ENdCategory:
       
   122             return U_DECIMAL_DIGIT_NUMBER;   //Nd
       
   123         case TChar::EPcCategory:
       
   124             return U_CONNECTOR_PUNCTUATION;
       
   125         case TChar::EPdCategory:
       
   126             return U_DASH_PUNCTUATION;
       
   127         case TChar::EPsCategory:
       
   128             return U_START_PUNCTUATION;
       
   129         case TChar::EPeCategory:
       
   130             return U_END_PUNCTUATION;
       
   131         case TChar::EPiCategory:
       
   132             return U_INITIAL_PUNCTUATION;
       
   133         case TChar::EPfCategory:
       
   134             return U_FINAL_PUNCTUATION;
       
   135         case TChar::EPoCategory:
       
   136             return U_OTHER_PUNCTUATION;
       
   137         case TChar::ESmCategory:
       
   138             return U_MATH_SYMBOL;
       
   139         case TChar::EScCategory:
       
   140             return U_CURRENCY_SYMBOL;
       
   141         case TChar::ESkCategory:
       
   142             return U_MODIFIER_SYMBOL;
       
   143         case TChar::ESoCategory:
       
   144             return U_OTHER_SYMBOL;
       
   145         case TChar::EZsCategory:
       
   146             return U_SPACE_SEPARATOR;
       
   147         case TChar::EZlCategory:
       
   148             return U_LINE_SEPARATOR;
       
   149         case TChar::EZpCategory:
       
   150             return U_PARAGRAPH_SEPARATOR;
       
   151         case TChar::ECcCategory:
       
   152             return U_CONTROL_CHAR;
       
   153         case TChar::ECfCategory:
       
   154             return U_FORMAT_CHAR;
       
   155         case TChar::ECsCategory:
       
   156             return U_SURROGATE;
       
   157         case TChar::ECoCategory:
       
   158             return U_PRIVATE_USE_CHAR;
       
   159         case TChar::ECnCategory:
       
   160             return U_GENERAL_OTHER_TYPES;
       
   161     };
       
   162 }
       
   163 
       
   164 U_STABLE UBool U_EXPORT2
       
   165 u_isdigit(UChar32 c) {
       
   166     return TChar(c).IsDigit();
       
   167 }
       
   168 
       
   169 U_STABLE int32_t U_EXPORT2
       
   170 u_getIntPropertyValue(UChar32 c, UProperty which) {
       
   171     // unimplemented
       
   172     return 0;
       
   173 }
       
   174 
       
   175 U_STABLE UChar32 U_EXPORT2
       
   176 u_totitle(UChar32 c) {
       
   177     return User::TitleCase(c);
       
   178 }
       
   179 
       
   180 const char mirrored_chars[] = {
       
   181     '<','>',
       
   182     '(',')',
       
   183     '[',']',
       
   184     '{','}',
       
   185     0
       
   186 };
       
   187 
       
   188 U_STABLE UChar32 U_EXPORT2
       
   189 u_charMirror(UChar32 c) {
       
   190     if (!TChar(c).IsMirrored())
       
   191         return c;
       
   192     int n=0;
       
   193     while(mirrored_chars[n] && mirrored_chars[n]!=c) n++;
       
   194     if (mirrored_chars[n]) {
       
   195         return mirrored_chars[n+(n%2?-1:1)];
       
   196     }
       
   197     return c;
       
   198 }
       
   199 
       
   200 U_STABLE UBool U_EXPORT2
       
   201 u_isUUppercase(UChar32 c) {
       
   202     return TChar(c).IsUpper();
       
   203 }
       
   204 
       
   205 U_STABLE uint8_t U_EXPORT2
       
   206 u_getCombiningClass(UChar32 c) {
       
   207     return TChar(c).GetCombiningClass();
       
   208 }
       
   209 
       
   210 #include <unicode/ustring.h>
       
   211 
       
   212 U_STABLE int32_t U_EXPORT2
       
   213 u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options) {
       
   214     return Mem::CompareF(s1,length,s2,length);
       
   215 }
       
   216 
       
   217 U_STABLE int32_t U_EXPORT2
       
   218 u_strToLower(UChar *dest, int32_t destCapacity,
       
   219              const UChar *src, int32_t srcLength,
       
   220              const char *locale,
       
   221              UErrorCode *pErrorCode) {
       
   222     if (srcLength==-1) {
       
   223         srcLength = 0;
       
   224         const UChar* p = src;
       
   225         while(*p++) srcLength++;
       
   226     }
       
   227     if (!dest || !destCapacity)
       
   228         return srcLength;
       
   229     int l = destCapacity<srcLength?destCapacity:srcLength;
       
   230     for (int n=0; n<l;n++)
       
   231         dest[n] = User::LowerCase(src[n]);
       
   232     return srcLength;
       
   233 }
       
   234 
       
   235 U_STABLE int32_t U_EXPORT2
       
   236 u_strToUpper(UChar *dest, int32_t destCapacity,
       
   237              const UChar *src, int32_t srcLength,
       
   238              const char *locale,
       
   239              UErrorCode *pErrorCode) {
       
   240     if (srcLength==-1) {
       
   241         srcLength = 0;
       
   242         const UChar* p = src;
       
   243         while(*p++) srcLength++;
       
   244     }
       
   245     if (!dest || !destCapacity)
       
   246         return srcLength;
       
   247     int l = destCapacity<srcLength?destCapacity:srcLength;
       
   248     for (int n=0; n<l;n++)
       
   249         dest[n] = User::UpperCase(src[n]);
       
   250     return srcLength;
       
   251 }
       
   252 
       
   253 U_STABLE int32_t U_EXPORT2
       
   254 u_strFoldCase(UChar *dest, int32_t destCapacity,
       
   255               const UChar *src, int32_t srcLength,
       
   256               uint32_t options,
       
   257               UErrorCode *pErrorCode) {
       
   258     if (srcLength==-1) {
       
   259         srcLength = 0;
       
   260         const UChar* p = src;
       
   261         while(*p++) srcLength++;
       
   262     }
       
   263     if (!dest || !destCapacity)
       
   264         return srcLength;
       
   265     int l = destCapacity<srcLength?destCapacity:srcLength;
       
   266     for (int n=0; n<l;n++)
       
   267         dest[n] = User::Fold(src[n]);
       
   268     return srcLength;
       
   269 }
       
   270 
       
   271 #include <unicode/ubrk.h>
       
   272 
       
   273 struct UBreakIteratorImpl {
       
   274     int textLength;
       
   275     int pos;
       
   276 };
       
   277 
       
   278 U_STABLE UBreakIterator* U_EXPORT2
       
   279 ubrk_open(UBreakIteratorType type,
       
   280       const char *locale,
       
   281       const UChar *text,
       
   282       int32_t textLength,
       
   283       UErrorCode *status) {
       
   284     UBreakIteratorImpl* bi = new UBreakIteratorImpl;
       
   285     bi->textLength = textLength;
       
   286     bi->pos = 0;
       
   287     return (UBreakIterator*)bi;
       
   288 }
       
   289 
       
   290 U_STABLE void U_EXPORT2
       
   291 ubrk_setText(UBreakIterator* bi,
       
   292              const UChar*    text,
       
   293              int32_t         textLength,
       
   294              UErrorCode*     status) {
       
   295     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   296     i->textLength = textLength;
       
   297     i->pos = 0;
       
   298 }
       
   299 
       
   300 U_STABLE void U_EXPORT2
       
   301 ubrk_close(UBreakIterator *bi) {
       
   302     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   303     delete i;
       
   304 }
       
   305 
       
   306 U_STABLE int32_t U_EXPORT2
       
   307 ubrk_first(UBreakIterator *bi) {
       
   308     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   309     i->pos = 0;
       
   310     return 0;
       
   311 }
       
   312 
       
   313 U_STABLE int32_t U_EXPORT2
       
   314 ubrk_preceding(UBreakIterator *bi,
       
   315            int32_t offset) {
       
   316     return offset?offset-1:UBRK_DONE;
       
   317 }
       
   318 
       
   319 U_STABLE int32_t U_EXPORT2
       
   320 ubrk_following(UBreakIterator *bi,
       
   321            int32_t offset) {
       
   322     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   323     return offset+1>=i->textLength?UBRK_DONE:offset+1;
       
   324 }
       
   325 
       
   326 U_STABLE int32_t U_EXPORT2
       
   327 ubrk_next(UBreakIterator *bi) {
       
   328     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   329     i->pos++;    
       
   330     return i->pos>=i->textLength?UBRK_DONE:i->pos;
       
   331 }
       
   332 
       
   333 U_STABLE int32_t U_EXPORT2
       
   334 ubrk_current(const UBreakIterator *bi) {
       
   335     UBreakIteratorImpl* i = (UBreakIteratorImpl*)bi;
       
   336     return i->pos;
       
   337 }
       
   338 
       
   339 #include <unicode/ucnv.h>
       
   340 
       
   341 U_STABLE void U_EXPORT2
       
   342 ucnv_toUnicode(UConverter *converter,
       
   343                UChar **target,
       
   344                const UChar *targetLimit,
       
   345                const char **source,
       
   346                const char *sourceLimit,
       
   347                int32_t *offsets,
       
   348                UBool flush,
       
   349                UErrorCode *err) {
       
   350     return;
       
   351 }
       
   352 
       
   353 U_STABLE const char * U_EXPORT2
       
   354 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode) {
       
   355     return 0;
       
   356 }
       
   357 
       
   358 U_STABLE void U_EXPORT2
       
   359 ucnv_setFromUCallBack (UConverter * converter,
       
   360                        UConverterFromUCallback newAction,
       
   361                        const void *newContext,
       
   362                        UConverterFromUCallback *oldAction,
       
   363                        const void **oldContext,
       
   364                        UErrorCode * err) {
       
   365     return;
       
   366 }
       
   367 
       
   368 U_STABLE void U_EXPORT2
       
   369 ucnv_setSubstChars(UConverter *converter,
       
   370                    const char *subChars,
       
   371                    int8_t len,
       
   372                    UErrorCode *err) {
       
   373     return;
       
   374 }
       
   375 
       
   376 U_STABLE void U_EXPORT2
       
   377 ucnv_fromUnicode (UConverter * converter,
       
   378                   char **target,
       
   379                   const char *targetLimit,
       
   380                   const UChar ** source,
       
   381                   const UChar * sourceLimit,
       
   382                   int32_t* offsets,
       
   383                   UBool flush,
       
   384                   UErrorCode * err) {
       
   385     return;
       
   386 }
       
   387 
       
   388 U_STABLE UConverter* U_EXPORT2
       
   389 ucnv_open(const char *converterName, UErrorCode *err) {
       
   390     return 0;
       
   391 }
       
   392 
       
   393 U_STABLE void  U_EXPORT2
       
   394 ucnv_close(UConverter * converter) {
       
   395     return;
       
   396 }
       
   397 
       
   398 #include <unicode/ucnv_err.h>
       
   399 
       
   400 U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_ESCAPE (
       
   401                   const void *context,
       
   402                   UConverterFromUnicodeArgs *fromUArgs,
       
   403                   const UChar* codeUnits,
       
   404                   int32_t length,
       
   405                   UChar32 codePoint,
       
   406                   UConverterCallbackReason reason,
       
   407                   UErrorCode * err) {
       
   408     return;
       
   409 }
       
   410 
       
   411 U_STABLE void U_EXPORT2 UCNV_FROM_U_CALLBACK_SUBSTITUTE (
       
   412                   const void *context,
       
   413                   UConverterFromUnicodeArgs *fromUArgs,
       
   414                   const UChar* codeUnits,
       
   415                   int32_t length,
       
   416                   UChar32 codePoint,
       
   417                   UConverterCallbackReason reason,
       
   418                   UErrorCode * err) {
       
   419     return;
       
   420 }
       
   421 
       
   422 
       
   423 #include <unicode/uidna.h>
       
   424 
       
   425 U_STABLE int32_t U_EXPORT2
       
   426 uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
       
   427                    UChar* dest, int32_t destCapacity,
       
   428                    int32_t options,
       
   429                    UParseError* parseError,
       
   430                    UErrorCode* status) {
       
   431     return 0;
       
   432 }
       
   433 
       
   434 #include <unicode/unorm.h>
       
   435 
       
   436 U_STABLE UNormalizationCheckResult U_EXPORT2
       
   437 unorm_quickCheck(const UChar *source, int32_t sourcelength,
       
   438                  UNormalizationMode mode,
       
   439                  UErrorCode *status) {
       
   440     return UNORM_YES;
       
   441 }
       
   442 
       
   443 
       
   444 U_STABLE int32_t U_EXPORT2
       
   445 unorm_normalize(const UChar *source, int32_t sourceLength,
       
   446                 UNormalizationMode mode, int32_t options,
       
   447                 UChar *result, int32_t resultLength,
       
   448                 UErrorCode *status) {
       
   449     return 0;
       
   450 }
       
   451 
       
   452 U_STABLE UChar* U_EXPORT2
       
   453 u_memset(UChar *dest, UChar c, int32_t count)
       
   454 {
       
   455     while( count-- ) {
       
   456         (*dest++) = c;
       
   457     }
       
   458     return dest;
       
   459 }