libemailfunctions

kasciistringtools.cpp
1 /*
2  kasciistringtools.cpp
3 
4  This file is part of libtdepim.
5 
6  Copyright (c) 2005 Ingo Kloecker <kloecker@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include "kasciistringtools.h"
25 
26 namespace KPIM {
27 
28 static unsigned char ASCIIToLower( unsigned char ch )
29 {
30  if ( ch >= 'A' && ch <= 'Z' )
31  return ch - 'A' + 'a';
32  else
33  return ch;
34 }
35 
36 char * kAsciiToLower( char *s )
37 {
38  if ( !s )
39  return 0;
40  for ( unsigned char *p = (unsigned char *) s; *p; ++p )
41  *p = ASCIIToLower( *p );
42  return s;
43 }
44 
45 static unsigned char ASCIIToUpper( unsigned char ch )
46 {
47  if ( ch >= 'a' && ch <= 'z' )
48  return ch - 'a' + 'A';
49  else
50  return ch;
51 }
52 
53 char * kAsciiToUpper( char *s )
54 {
55  if ( !s )
56  return 0;
57  for ( unsigned char *p = (unsigned char *) s; *p; ++p )
58  *p = ASCIIToUpper( *p );
59  return s;
60 }
61 
62 } // namespace KPIM
KPIM holds all kinds of functions specific to KDE PIM.
Definition: email.h:38
char * kAsciiToLower(char *s)
Locale-independent function to convert ASCII strings to lower case ASCII strings.
char * kAsciiToUpper(char *s)
Locale-independent function to convert ASCII strings to upper case ASCII strings.