commit 97acb934ae410fc8a9be51f3272d7b504750eec5 parent 1c51871a3658bf9316856f6237200c76e801bd26 Author: ByteProject <stefan.vogt@byteproject.net> Date: Wed, 21 Dec 2011 10:57:49 +0100 implementation of PHP's strtolower() in ANSI C Diffstat:
A | ansilove/strtolower.h | | | 16 | ++++++++++++++++ |
A | ansilove/strtolower.m | | | 21 | +++++++++++++++++++++ |
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/ansilove/strtolower.h b/ansilove/strtolower.h @@ -0,0 +1,16 @@ +// +// strtolower.h +// AnsiLove/ObjC +// +// Copyright (c) 2011, Stefan Vogt. All rights reserved. +// http://byteproject.net +// +// Use of this source code is governed by a MIT-style license. +// See the file LICENSE for details. +// + +#import <Foundation/Foundation.h> + +// In-place modification of a string to be all lower case. + +void strtolower(char str[]); diff --git a/ansilove/strtolower.m b/ansilove/strtolower.m @@ -0,0 +1,21 @@ +// +// strtolower.m +// AnsiLove/ObjC +// +// Copyright (c) 2011, Stefan Vogt. All rights reserved. +// http://byteproject.net +// +// Use of this source code is governed by a MIT-style license. +// See the file LICENSE for details. +// + +#import "strtolower.h" + +void strtolower(char str[]) { + while(*str != 0) { + if (*str >= 'A' && *str <= 'Z') { + *str = *str + 'a' - 'A'; + } + str++; + } +}