• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • text
kascii.cpp
Go to the documentation of this file.
1 /* -*- c++ -*-
2  Copyright (c) 2005 Ingo Kloecker <kloecker@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kascii.h"
21 
22 int kasciistricmp( const char *str1, const char *str2 )
23 {
24  const unsigned char *s1 = (const unsigned char *)str1;
25  const unsigned char *s2 = (const unsigned char *)str2;
26  int res;
27  unsigned char c1, c2;
28 
29  if ( !s1 || !s2 )
30  return s1 ? 1 : (s2 ? -1 : 0);
31  if ( !*s1 || !*s2 )
32  return *s1 ? 1 : (*s2 ? -1 : 0);
33  for (;*s1; ++s1, ++s2) {
34  c1 = *s1; c2 = *s2;
35  if (c1 >= 'A' && c1 <= 'Z')
36  c1 += 'a' - 'A';
37  if (c2 >= 'A' && c2 <= 'Z')
38  c2 += 'a' - 'A';
39 
40  if ((res = c1 - c2))
41  break;
42  }
43  return *s1 ? res : (*s2 ? -1 : 0);
44 }
45 
50 static unsigned char ASCIIToLower( unsigned char ch )
51 {
52  if ( ch >= 'A' && ch <= 'Z' )
53  return ch - 'A' + 'a';
54  else
55  return ch;
56 }
57 
58 char * kAsciiToLower( char *s )
59 {
60  if ( !s )
61  return 0;
62  for ( unsigned char *p = (unsigned char *) s; *p; ++p )
63  *p = ASCIIToLower( *p );
64  return s;
65 }
66 
71 static unsigned char ASCIIToUpper( unsigned char ch )
72 {
73  if ( ch >= 'a' && ch <= 'z' )
74  return ch - 'a' + 'A';
75  else
76  return ch;
77 }
78 
79 char * kAsciiToUpper( char *s )
80 {
81  if ( !s )
82  return 0;
83  for ( unsigned char *p = (unsigned char *) s; *p; ++p )
84  *p = ASCIIToUpper( *p );
85  return s;
86 }
87 
ASCIIToUpper
static unsigned char ASCIIToUpper(unsigned char ch)
Convert a single ASCII character to uppercase.
Definition: kascii.cpp:71
kAsciiToUpper
char * kAsciiToUpper(char *s)
Locale-independent function to convert ASCII strings to upper case ASCII strings. ...
Definition: kascii.cpp:79
ASCIIToLower
static unsigned char ASCIIToLower(unsigned char ch)
Convert a single ASCII character to lowercase.
Definition: kascii.cpp:50
kasciistricmp
int kasciistricmp(const char *str1, const char *str2)
Locale-independent qstricmp.
Definition: kascii.cpp:22
kAsciiToLower
char * kAsciiToLower(char *s)
Locale-independent function to convert ASCII strings to lower case ASCII strings. ...
Definition: kascii.cpp:58
kascii.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal