genericopenlibs/openenvcore/libc/src/iswctype.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : iswctype.cpp
       
    15 // Part of     : LIBC
       
    16 // Contains the source for fchdir
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21  
       
    22 #include <e32std.h>
       
    23 #include <wctype.h>
       
    24 
       
    25 extern "C" {
       
    26 //-----------------------------------------------------------------------------
       
    27 //Function Name : int iswalpha(wint_t i)
       
    28 //Description   : tests whether wc is a wide character belonging to the wide
       
    29 //character class "alpha".
       
    30 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
    31 //the  wide  character class "alpha". Otherwise it returns zero.
       
    32 //-----------------------------------------------------------------------------
       
    33 EXPORT_C int iswalpha(wint_t i)
       
    34 {
       
    35 	TChar::TCharInfo uInfo;
       
    36 
       
    37 	TChar((TUint)i).GetInfo(uInfo);
       
    38 	if((uInfo.iCategory == (TChar::ELuCategory))  || 
       
    39 	 	(uInfo.iCategory == (TChar::ELlCategory)) ||
       
    40 	 	(uInfo.iCategory == (TChar::ELtCategory)) ||
       
    41 	 	(uInfo.iCategory == (TChar::ELoCategory)))
       
    42 	{
       
    43 		return (1);
       
    44 	}
       
    45 	else
       
    46 	{
       
    47 		return (0);
       
    48 	}
       
    49 } //end of function
       
    50 
       
    51 //-----------------------------------------------------------------------------
       
    52 //Function Name : int iswalnum(wint_t i)
       
    53 //Description   : tests whether wc is a wide character belonging to the wide
       
    54 //character class "alnum".
       
    55 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
    56 //the  wide  character class "alnum". Otherwise it returns zero.
       
    57 //-----------------------------------------------------------------------------
       
    58 EXPORT_C int iswalnum(wint_t i)
       
    59 {
       
    60 	TChar::TCharInfo uInfo;
       
    61 	
       
    62 	TChar((TUint)i).GetInfo(uInfo);
       
    63 	if((uInfo.iCategory == (TChar::ENdCategory)) || 
       
    64 		(uInfo.iCategory == (TChar::ELlCategory)) || 
       
    65 		(uInfo.iCategory == (TChar::ELuCategory)) ||
       
    66 	 	(uInfo.iCategory == (TChar::ELtCategory)) ||
       
    67 	 	(uInfo.iCategory == (TChar::ELoCategory)))
       
    68 	{
       
    69 		return (1);
       
    70 	}
       
    71 	else
       
    72 	{
       
    73 		return (0);
       
    74 	}
       
    75 } //end of function
       
    76 
       
    77 //-----------------------------------------------------------------------------
       
    78 //Function Name : int iswblank(wint_t i)
       
    79 //Description   : tests whether wc is a wide character belonging to the wide
       
    80 //character class "blank".
       
    81 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
    82 //the  wide  character class "blank". Otherwise it returns zero.
       
    83 //-----------------------------------------------------------------------------
       
    84 EXPORT_C int iswblank(wint_t i)
       
    85 {
       
    86 	const TUint KHorizontalTab = 0x09;
       
    87 	TChar::TCharInfo uInfo;
       
    88 	
       
    89 	TChar((TUint)i).GetInfo(uInfo);
       
    90 	if((uInfo.iCategory == (TChar::EZsCategory)) || 
       
    91 		((uInfo.iCategory == (TChar::EControlGroup)) &&
       
    92 		(uInfo.iBdCategory == (TChar::ESegmentSeparator)) &&
       
    93 		(uInfo.iLowerCase == KHorizontalTab )))
       
    94 	{
       
    95 		return (1);
       
    96 	}
       
    97 	else
       
    98 	{
       
    99 		return (0);
       
   100 	}
       
   101 } //end of function
       
   102 
       
   103 //-----------------------------------------------------------------------------
       
   104 //Function Name : int iswcntrl(wint_t i)
       
   105 //Description   : tests whether wc is a wide character belonging to the wide
       
   106 //character class "cntrl".
       
   107 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   108 //the  wide  character class "cntrl". Otherwise it returns zero.
       
   109 //-----------------------------------------------------------------------------
       
   110 EXPORT_C int iswcntrl(wint_t i)
       
   111 {
       
   112 	TChar::TCharInfo uInfo;
       
   113 	
       
   114 	TChar((TUint)i).GetInfo(uInfo);
       
   115 	if((uInfo.iCategory == (TChar::EZlCategory))  ||
       
   116 		(uInfo.iCategory == (TChar::EZpCategory)) ||
       
   117 		(uInfo.iCategory == (TChar::ECcCategory)) ||
       
   118 		(uInfo.iCategory == (TChar::ECfCategory)))
       
   119 	{
       
   120 		return (1);
       
   121 	}
       
   122 	else
       
   123 	{
       
   124 		return (0);
       
   125 	}
       
   126 } //end of function
       
   127 
       
   128 //-----------------------------------------------------------------------------
       
   129 //Function Name : int iswdigit(wint_t i)
       
   130 //Description   : tests whether wc is a wide character belonging to the wide
       
   131 //character class "digit".
       
   132 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   133 //the  wide  character class "digit". Otherwise it returns zero.
       
   134 //-----------------------------------------------------------------------------
       
   135 EXPORT_C int iswdigit(wint_t i)
       
   136 {
       
   137 	TChar::TCharInfo uInfo;
       
   138 		
       
   139 	TChar((TUint)i).GetInfo(uInfo);
       
   140 	if(uInfo.iCategory == (TChar::ENdCategory))
       
   141 	{
       
   142 		return (1);
       
   143 	}
       
   144 	else
       
   145 	{
       
   146 		return (0);
       
   147 	}
       
   148 } //end of function
       
   149 
       
   150 //-----------------------------------------------------------------------------
       
   151 //Function Name : int iswprint(wint_t i)
       
   152 //Description   : tests whether wc is a wide character belonging to the wide
       
   153 //character class "print".
       
   154 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   155 //the  wide  character class "print". Otherwise it returns zero.
       
   156 //-----------------------------------------------------------------------------
       
   157 EXPORT_C int iswprint(wint_t i)
       
   158 {
       
   159 	TChar::TCharInfo uInfo;
       
   160 	
       
   161 	TChar((TUint)i).GetInfo(uInfo);
       
   162 	if((uInfo.iCategory == (TChar::ELuCategory))  || 
       
   163 	 	(uInfo.iCategory == (TChar::ELlCategory)) ||
       
   164 	 	(uInfo.iCategory == (TChar::ELtCategory)) ||
       
   165 	 	(uInfo.iCategory == (TChar::ELoCategory)) ||
       
   166 	 	(uInfo.iCategory == (TChar::ELmCategory)) || 
       
   167 	 	(uInfo.iCategory == (TChar::EMnCategory)) ||
       
   168 	 	(uInfo.iCategory == (TChar::EMcCategory)) ||
       
   169 	 	(uInfo.iCategory == (TChar::EMeCategory)) ||
       
   170 	 	(uInfo.iCategory == (TChar::ENdCategory)) || 
       
   171 	 	(uInfo.iCategory == (TChar::ENoCategory)) ||
       
   172 	 	(uInfo.iCategory == (TChar::EPcCategory)) ||
       
   173 	 	(uInfo.iCategory == (TChar::EPdCategory)) ||
       
   174 	 	(uInfo.iCategory == (TChar::EPsCategory)) || 
       
   175 	 	(uInfo.iCategory == (TChar::EPeCategory)) ||
       
   176 	 	(uInfo.iCategory == (TChar::EPiCategory)) ||
       
   177 	 	(uInfo.iCategory == (TChar::EPfCategory)) ||
       
   178 	 	(uInfo.iCategory == (TChar::EPoCategory)) || 
       
   179 	 	(uInfo.iCategory == (TChar::ESmCategory)) ||
       
   180 	 	(uInfo.iCategory == (TChar::EScCategory)) ||
       
   181 	 	(uInfo.iCategory == (TChar::ESkCategory)) ||
       
   182 	 	(uInfo.iCategory == (TChar::ESoCategory)) ||
       
   183 	 	(uInfo.iCategory == (TChar::EZsCategory)))
       
   184 	{
       
   185 		return (1);
       
   186 	}
       
   187 	else
       
   188 	{
       
   189 		return (0);
       
   190 	}
       
   191 } //end of function
       
   192 	
       
   193 //-----------------------------------------------------------------------------
       
   194 //Function Name : int iswlower(wint_t i)
       
   195 //Description   : tests whether wc is a wide character belonging to the wide
       
   196 //character class "lower".
       
   197 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   198 //the  wide  character class "lower". Otherwise it returns zero.
       
   199 //-----------------------------------------------------------------------------
       
   200 EXPORT_C int iswlower(wint_t i)
       
   201 {
       
   202 	TChar::TCharInfo uInfo;
       
   203 
       
   204 	TChar((TUint)i).GetInfo(uInfo);
       
   205 	if((uInfo.iCategory == (TChar::ELlCategory)))
       
   206 	{
       
   207 		return (1);
       
   208 	}
       
   209 	else
       
   210 	{
       
   211 		return (0);
       
   212 	}
       
   213 } //end of function
       
   214 
       
   215 //-----------------------------------------------------------------------------
       
   216 //Function Name : int iswgraph(wint_t i)
       
   217 //Description   : tests whether wc is a wide character belonging to the wide
       
   218 //character class "graph".
       
   219 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   220 //the  wide  character class "graph". Otherwise it returns zero.
       
   221 //-----------------------------------------------------------------------------
       
   222 EXPORT_C int iswgraph(wint_t i)
       
   223 {
       
   224 	TChar::TCharInfo uInfo;
       
   225 	
       
   226 	TChar((TUint)i).GetInfo(uInfo);
       
   227 	if((uInfo.iCategory == (TChar::ELuCategory))  || 
       
   228 	 	(uInfo.iCategory == (TChar::ELlCategory)) ||
       
   229 	 	(uInfo.iCategory == (TChar::ELtCategory)) ||
       
   230 	 	(uInfo.iCategory == (TChar::ELoCategory)) ||
       
   231 	 	(uInfo.iCategory == (TChar::ELmCategory)) || 
       
   232 	 	(uInfo.iCategory == (TChar::EMnCategory)) ||
       
   233 	 	(uInfo.iCategory == (TChar::EMcCategory)) ||
       
   234 	 	(uInfo.iCategory == (TChar::EMeCategory)) ||
       
   235 	 	(uInfo.iCategory == (TChar::ENdCategory)) || 
       
   236 	 	(uInfo.iCategory == (TChar::ENoCategory)) ||
       
   237 	 	(uInfo.iCategory == (TChar::EPcCategory)) ||
       
   238 	 	(uInfo.iCategory == (TChar::EPdCategory)) ||
       
   239 	 	(uInfo.iCategory == (TChar::EPsCategory)) || 
       
   240 	 	(uInfo.iCategory == (TChar::EPeCategory)) ||
       
   241 	 	(uInfo.iCategory == (TChar::EPiCategory)) ||
       
   242 	 	(uInfo.iCategory == (TChar::EPfCategory)) ||
       
   243 	 	(uInfo.iCategory == (TChar::EPoCategory)) || 
       
   244 	 	(uInfo.iCategory == (TChar::ESmCategory)) ||
       
   245 	 	(uInfo.iCategory == (TChar::EScCategory)) ||
       
   246 	 	(uInfo.iCategory == (TChar::ESkCategory)) ||
       
   247 	 	(uInfo.iCategory == (TChar::ESoCategory)))
       
   248 	{
       
   249 		return (1);
       
   250 	}
       
   251 	else
       
   252 	{
       
   253 		return (0);
       
   254 	}
       
   255 } //end of function
       
   256 
       
   257 //-----------------------------------------------------------------------------
       
   258 //Function Name : int iswpunct(wint_t i)
       
   259 //Description   : tests whether wc is a wide character belonging to the wide
       
   260 //character class "punct".
       
   261 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   262 //the  wide  character class "punct". Otherwise it returns zero.
       
   263 //-----------------------------------------------------------------------------
       
   264 EXPORT_C int iswpunct(wint_t i)
       
   265 {
       
   266 	TChar::TCharInfo uInfo;
       
   267 	
       
   268 	TChar((TUint)i).GetInfo(uInfo);
       
   269 	if((uInfo.iCategory == (TChar::EPcCategory))  ||
       
   270 		(uInfo.iCategory == (TChar::EPdCategory)) ||
       
   271 		(uInfo.iCategory == (TChar::EPsCategory)) ||
       
   272 		(uInfo.iCategory == (TChar::EPeCategory)) ||
       
   273 		(uInfo.iCategory == (TChar::EPiCategory)) ||
       
   274 		(uInfo.iCategory == (TChar::EPfCategory)) ||
       
   275 		(uInfo.iCategory == (TChar::EPoCategory)) ||
       
   276 		((uInfo.iCategory == (TChar::EScCategory)  &&
       
   277 	     (uInfo.iBdCategory ==((TChar::EEuropeanNumberTerminator))))) ||
       
   278 	    ((uInfo.iCategory == (TChar::ESymbolGroup) &&
       
   279 	     (uInfo.iBdCategory ==((TChar::EEuropeanNumberTerminator))))) ||
       
   280 	    ((uInfo.iCategory == (TChar::ESymbolGroup) &&
       
   281 	     (uInfo.iBdCategory ==((TChar::EOtherNeutral))))) ||
       
   282 	     ((uInfo.iCategory == (TChar::ESkCategory) &&
       
   283 	     (uInfo.iBdCategory ==((TChar::EOtherNeutral))))))
       
   284 	{
       
   285 		return (1);
       
   286 	}
       
   287 	else
       
   288 	{
       
   289 		return (0);
       
   290 	}
       
   291 } //end of function
       
   292 
       
   293 //-----------------------------------------------------------------------------
       
   294 //Function Name : int iswspace(wint_t i)
       
   295 //Description   : tests whether wc is a wide character belonging to the wide
       
   296 //character class "space".
       
   297 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   298 //the  wide  character class "space". Otherwise it returns zero.
       
   299 //-----------------------------------------------------------------------------
       
   300 EXPORT_C int iswspace(wint_t i)
       
   301 {
       
   302 	return (TChar((TUint)i).IsSpace());
       
   303 } //end of function
       
   304 
       
   305 //-----------------------------------------------------------------------------
       
   306 //Function Name : int iswupper(wint_t i)
       
   307 //Description   : tests whether wc is a wide character belonging to the wide
       
   308 //character class "upper".
       
   309 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   310 //the  wide  character class "upper". Otherwise it returns zero.
       
   311 //-----------------------------------------------------------------------------
       
   312 EXPORT_C int iswupper(wint_t i)
       
   313 {
       
   314 	TChar::TCharInfo uInfo;
       
   315 	
       
   316 	TChar((TUint)i).GetInfo(uInfo);
       
   317 	if((uInfo.iCategory == (TChar::ELuCategory)))
       
   318 	{
       
   319 		return (1);
       
   320 	}
       
   321 	else
       
   322 	{
       
   323 		return (0);
       
   324 	}
       
   325 } //end of function
       
   326 
       
   327 //-----------------------------------------------------------------------------
       
   328 //Function Name : int iswxdigit(wint_t i)
       
   329 //Description   : tests whether wc is a wide character belonging to the wide
       
   330 //character class "xdigit".
       
   331 //Return Value  : returns  non-zero  if  i is  a  wide  character belonging to
       
   332 //the  wide  character class "xdigit". Otherwise it returns zero.
       
   333 //-----------------------------------------------------------------------------
       
   334 EXPORT_C int iswxdigit(wint_t i)
       
   335 {
       
   336 	TChar::TCharInfo uInfo;
       
   337 	
       
   338 	TChar((TUint)i).GetInfo(uInfo);
       
   339 	if((((uInfo.iCategory == (TChar::ELlCategory)) || (uInfo.iCategory == (TChar::ELuCategory))) && 
       
   340 			((i >= L'a' && i <= L'f') || (i >= L'A' && i <= L'F'))) ||
       
   341 			(uInfo.iCategory == (TChar::ENdCategory)))
       
   342 	{
       
   343 		return (1);
       
   344 	}
       
   345 	else
       
   346 	{
       
   347 		return (0);
       
   348 	}
       
   349 } //end of function
       
   350     
       
   351 //-----------------------------------------------------------------------------
       
   352 //Function Name : wint_t towlower(wint_t i)
       
   353 //Description   :If i is a wide character,  it  is  converted  to  lowercase.
       
   354 //Characters  which  do  not  have case are returned unchanged.
       
   355 //Return Value  :returns the lowercase equivalent of i, or  WEOF if i is WEOF
       
   356 //-----------------------------------------------------------------------------
       
   357 EXPORT_C wint_t towlower(wint_t i)
       
   358 {
       
   359 	TChar::TCharInfo uInfo;
       
   360 
       
   361 	TChar((TUint)i).GetInfo(uInfo);
       
   362 	return (uInfo.iLowerCase);
       
   363 } //end of function
       
   364 
       
   365 //-----------------------------------------------------------------------------
       
   366 //Function Name : wint_t towupper(wint_t i)
       
   367 //Description   :If i is a wide character,  it  is  converted  to  uppercase.
       
   368 //Characters  which  do  not  have case are returned unchanged.
       
   369 //Return Value  :returns the uppercase equivalent of i, or  WEOF if i is WEOF
       
   370 //-----------------------------------------------------------------------------
       
   371 EXPORT_C wint_t towupper(wint_t i)
       
   372 {
       
   373 	TChar::TCharInfo uInfo;
       
   374 	
       
   375 	TChar((TUint)i).GetInfo(uInfo);
       
   376 	return (uInfo.iUpperCase);
       
   377 } //end of function
       
   378 
       
   379 } // extern "C"