From 453da9a6df16dee551c7a590343c4f77be23d4e4 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 3 Dec 2023 11:21:57 -0500 Subject: [PATCH] cwText : Added toLower() and toUpper(). --- cwText.cpp | 15 +++++++++++++++ cwText.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/cwText.cpp b/cwText.cpp index 4ed9a69..f8d0007 100644 --- a/cwText.cpp +++ b/cwText.cpp @@ -54,6 +54,21 @@ namespace cw unsigned cw::textLength( const char* s ) { return s == nullptr ? 0 : strlen(s); } +void textToLower( char* s ) +{ + if( s != nullptr ) + for(; *s; ++s) + *s = std::tolower(*s); +} + +void textToUpper( char* s ) +{ + if( s != nullptr ) + for(; *s; ++s) + *s = std::toupper(*s); +} + + int cw::textCompare( const char* s0, const char* s1 ) { if( s0 == nullptr || s1 == nullptr ) diff --git a/cwText.h b/cwText.h index 64f579d..aff115f 100644 --- a/cwText.h +++ b/cwText.h @@ -6,6 +6,9 @@ namespace cw { // Return 0 if s is null. unsigned textLength( const char* s ); + + void textToLower( char* s ); + void textToUpper( char* s ); // Note: if both s0 and s1 are nullptr then a match is indicated int textCompare( const char* s0, const char* s1 );