Andrew Scheurer

Palm OS Codewarrior 9.3 w/ broken tolower, toupper

Discussion created by Andrew Scheurer on Sep 20, 2006
Latest reply on Sep 20, 2006 by Tom Thompson
I'm trying to change the character string to upper case or lower case. I find it strange that Palm OS API has a StrToLower function but no StrToUpper function but StrToLower Palm OS API does work but I need to convert to lower and upper and so I resort to tolower and toupper as portable solutions.
 
First I tried to do it the std C++ way with std::transform(s.begin(), s.end(), s.begin, ::toupper);
and this compiled and linked but its execution erased my string - obliterated it, so then I tried
 
// Explicit cast forces the compiler to choose the function def over the macro
std::transform(s.begin(), s.end(), s.begin, (int(*)(int))toupper);
This gave a compiler error and I had to abandon it. If toupper is a macro then no forcing it will work.
 
Finally I resorted the std hack:
strupr((char*)s.c_str()); -- this wouldn't compile, strupr wasn't found even though I had string.h included.
 
Finally I then I just wrote my own function
strupr(char* s)
which called
s[i] = toupper(s[i])
and s[i] which had the character string "abc"
but got a 0 result.
0 <= s[i] = toupper(s[i]) even though s[i] was = to 'A'
toupper was not working. I was thinking this had to something to do w/ the locale.
 
All I can conclude is that toupper and tolower do not work with the Palm OS Metrowerks compiler.
 
Finally I put at the top of the .cpp file, since the IDE doesn't let one define a -D_MSL_USE_INLINE anywhere which a typical compiler - GUI or cmd line usually does...
 
#define _MSL_USE_INLINE 1
and now FINALLY toupper works...
 
What is going wrong?
I isolated the code to the file <cctype> and I'm using the latest 9.3.
 
Is there a configuration for this compiler that lets me write std C++ code or at least close to it.
Is there a way to use -D_MSL_USE_INLINE or do I need to use the cmd line compiler for that. Is it even advisable to use this macro - if I don't it - it compiles and links but tolower and toupper always return 0.
 
I'm porting an existing app that is fairly small and I don't want to have to write all the std C and C++ functions just for the Palm OS and do all these mental gymnastics.
 
 
 
 
 

 

Outcomes