kasciistringtools.cpp
00001 /* -*- c++ -*- 00002 kasciistringtools.cpp 00003 00004 This file is part of libkdepim. 00005 00006 Copyright (c) 2005 Ingo Kloecker <kloecker@kde.org> 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 00024 #include "kasciistringtools.h" 00025 00026 namespace KPIM { 00027 00028 static unsigned char ASCIIToLower( unsigned char ch ) 00029 { 00030 if ( ch >= 'A' && ch <= 'Z' ) 00031 return ch - 'A' + 'a'; 00032 else 00033 return ch; 00034 } 00035 00036 char * kAsciiToLower( char *s ) 00037 { 00038 if ( !s ) 00039 return 0; 00040 for ( unsigned char *p = (unsigned char *) s; *p; ++p ) 00041 *p = ASCIIToLower( *p ); 00042 return s; 00043 } 00044 00045 static unsigned char ASCIIToUpper( unsigned char ch ) 00046 { 00047 if ( ch >= 'a' && ch <= 'z' ) 00048 return ch - 'a' + 'A'; 00049 else 00050 return ch; 00051 } 00052 00053 char * kAsciiToUpper( char *s ) 00054 { 00055 if ( !s ) 00056 return 0; 00057 for ( unsigned char *p = (unsigned char *) s; *p; ++p ) 00058 *p = ASCIIToUpper( *p ); 00059 return s; 00060 } 00061 00062 } // namespace KPIM