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

KDECore

  • 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
22int 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
50static 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
58char * 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
71static 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
79char * 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
kAsciiToLower
char * kAsciiToLower(char *s)
Locale-independent function to convert ASCII strings to lower case ASCII strings.
Definition: kascii.cpp:58
kAsciiToUpper
char * kAsciiToUpper(char *s)
Locale-independent function to convert ASCII strings to upper case ASCII strings.
Definition: kascii.cpp:79
ASCIIToUpper
static unsigned char ASCIIToUpper(unsigned char ch)
Convert a single ASCII character to uppercase.
Definition: kascii.cpp:71
kasciistricmp
int kasciistricmp(const char *str1, const char *str2)
Locale-independent qstricmp.
Definition: kascii.cpp:22
ASCIIToLower
static unsigned char ASCIIToLower(unsigned char ch)
Convert a single ASCII character to lowercase.
Definition: kascii.cpp:50
kascii.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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